0
我有一個部分View
,從Action
加載的,所以父視圖包含:不顯眼的驗證editorfor
@Html.Action("TourSearch")
的TourSearch查看使用編輯器,例如:
@Html.EditorFor(model => model.ImpersonatedAgentModel, "ImpersonatedAgentView")
其中ImpersonatedAgentModel
是這樣的:
[Serializable]
public class ImpersonatedAgentModel
{
[Required(ErrorMessage = "Please provide a User ref")]
public string AgentImpersonatedUserName { get; set; }
[Required(ErrorMessage="Please provide a ABTA/AgencyCode")]
public string AgentImpersonatedBranchCode { get; set; }
[Required(ErrorMessage = "Please provide a User ref")]
public int? AgentImpersonatedBranchID { get; set; }
}
我的編輯器很漂亮raight forward:
@model Travel2.WebUI.Models.ImpersonatedAgentModel
<ul id="agencyDetails">
<li>
<label for="AgentImpersonatedBranchCode">ABTA/Agency Code: *</label>
@Html.TextBoxFor(model => model.AgentImpersonatedBranchCode, new {ID="txtBranchCode" })
@Html.ValidationMessageFor(model => model.AgentImpersonatedBranchCode, "*")
<input id="txtBranchId", type="hidden" value="@Model.AgentImpersonatedBranchID" />
<input id="txtUserName", type="hidden" value="@Model.AgentImpersonatedUserName" />
<input id="hidCurrentController" type="hidden" value='@ViewContext.Controller.ValueProvider.GetValue("controller").RawValue' />
</li>
<li>
<label for="AgentImpersonatedUserName">User ref: *</label>
<select id="ddlUser" disabled="disabled" ></select>
<input type="hidden" id="txtUserID" />
@Html.HiddenFor(model => model.AgentImpersonatedUserName, new {ID="AgentImpersonatedUserName" })
@Html.HiddenFor(model => model.AgentImpersonatedBranchID, new {ID="AgentImpersonatedBranchID"})
@Html.ValidationMessageFor(model => model.AgentImpersonatedUserName, "*")
</li>
</ul>
現在在Chrome中,一切正常。但是當我填寫表格IE而不是編輯器中的數據時,它通過驗證不正確!
如果我檢查標記,使用IE的藉口差Firebug的,我可以看到驗證屬性,
<input name="ImpersonatedAgentModel.AgentImpersonatedBranchCode" id="txtBranchCode" type="text" data-val="true" data-val-required="Please provide a ABTA/AgencyCode" jQuery172048066185567747205="94"/>
那麼爲什麼IE忽略他們!愚蠢的IE
什麼版本的IE瀏覽器您使用的是? – Robert
IE 9.不兼容模式 – Liam
你有兩個編輯器導致完整的編輯器代碼使用TextBoxFor – Robert