我从View
加载了部分Action
,因此父视图包含:
@Html.Action("TourSearch")
TourSearch View使用编辑器:
@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; }
}
我的编辑很直接:
@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 中的表单而不是编辑器中的数据时,它会错误地通过验证!
如果我检查标记,使用IEs对Firebug的不良借口,我可以看到验证属性,
<input name="ImpersonatedAgentModel.AgentImpersonatedBranchCode" id="txtBranchCode" type="text" data-val="true" data-val-required="Please provide a ABTA/AgencyCode" jQuery172048066185567747205="94"/>
那么为什么IE会忽略它们!愚蠢的IE
答案 0 :(得分:1)
在这里找到答案:
我们也引用了Jquery验证,这似乎导致了这个错误