Question

I have a problem. You see,

I've got this code (MVC3)

@Using Html.BeginForm()
 @Html.ValidationSummary(True, "Please review errors.")

 @<fieldset>
 <legend>Fields</legend>
        <p>
            @Html.LabelFor(Function(Model) Model.ID_PROVINCIA, "Code:")
            @Html.TextBox("ID_PROVINCIA", "Automatic", New With {.readonly = "readonly"})
        </p>
        <p>
            @Html.LabelFor(Function(Model) Model.DESC_PROVINCIA, "Name:")
            @Html.TextBoxFor(Function(Model) Model.DESC_PROVINCIA, New With {.style = "text-transform:uppercase"})
        </p>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>

    @<div>
        @Html.ActionLink(" ", "List", "Administration", New With {.area = ""}, New With {.class = "imgBack", .title = "Back"})
    </div>
End Using

if I use @Html.ValidationSummary(True, "Please review errors.") nothing happend on submit. If I use @Html.ValidationSummary(False, "Please review errors.") I get error: "The field ID_PROVINCIA must be a number"

I need to exclude this comprobation on ID_PROVINCIA when submit form, because with text "Automatic" the users know the ID number is assign automatically.

In the controller I've got:

<AcceptVerbs(HttpVerbs.Post)> _
Function Create(<Bind(Exclude:="ID_PROVINCIA")> ByVal parProvincia As PROVINCIA) As ActionResult
End Function

In MVC2 there was no problem, actually i'm trying to migrate the app. Any idea??
Regards.

Was it helpful?

Solution

I resolve the problem changing

@Html.TextBox("ID_PROVINCIA", "Automatic", New With {.readonly = "readonly"})    

to

@Html.TextBox("ID_PROVINCIA1", "Automatic", New With {.readonly = "readonly"})

This is because I'm not using TextBoxFor for Model and the controller Bind-Exclude ID_PROVINCIA.

See ya.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top