2011-01-31 60 views
0

我遇到問題。你看,從驗證摘要中排除MVC3

如果我使用@ Html.ValidationSummary(真, 「請檢查錯誤。」)沒有happend上提交我有了這個代碼(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 

。如果我使用@ Html.ValidationSummary(假,「請檢查錯誤」)我得到錯誤:「這個領域ID_PROVINCIA必須是數字」

我需要排除的ID_PROVINCIA此comprobation提交表單的時候,因爲有文本「自動」,用戶知道ID號碼自動分配。

在控制器我有:

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

在MVC2沒有什麼問題,其實我試圖遷移的應用程序。任何想法??
此致敬禮。

+0

好的。在HTML代碼中** data-val **被設置爲**「true」**。有沒有辦法將此值更改爲** false **。我正在使用由EF4 edmx Model抽象生成的PROVINCIA類 – 2011-02-01 15:37:30

回答

0

我決心改變

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

的問題

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

這是因爲我沒有使用TextBoxFor型號和控制器綁定 - 排除ID_PROVINCIA。

看到你。