I.E中的局部视图验证错误

时间:2012-12-03 12:03:15

标签: jquery asp.net-mvc

我在另一个视图中有局部视图。 部分视图是“登录”部分。我正在使用jquery验证。 请参阅附图。

enter image description here 这里的要求是,谁已经注册,他们将输入用户名/密码并继续下一页。 (在登录局部视图中) 那些还没有签名的人,他们会输入电子邮件/密码/全名并进入下一页。(在主视图中)

在主视图中,几乎没有必填字段。例如:电子邮件,密码等。 现在的问题是,如果我在登录局部视图中输入用户名/密码, 它不允许我继续。它给了我主视图中必填字段的错误。

这只发生在I.E. 在FF和Crome中,它可以按照我想要的方式工作。

知道在这种情况下该怎么做??

CODE: 登录部分:

<script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>"    type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>"     type="text/javascript"></script>

<% using (Html.BeginForm("LogOn", "Account", new { returnUrl =     Request.QueryString["returnUrl"] }))
 { %>

<div>
        <div class="editor-label">
            <%:Html.Label("Email") %>

        </div>
        <div class="editor-field">

             <%:Html.TextBoxFor(m => m.UserName, new { style = "width:350px;" })%>
        </div>
        <div class="editor-label">
             <%:Html.LabelFor(m => m.Password)%>
        </div>
        <div class="editor-field">

            <%:Html.PasswordFor(m => m.Password, new { style = "width:350px;" })%> 
        </div>
        <p>
            <input type="image" value="Log On" title="Log On"     src="../../Content/images/signinnew.png"/>
        </p>
</div>
<%} %>

主要观点:

<script type="text/javascript">
$(document).ready(function () {

    <%if (User.Identity.IsAuthenticated)
    { %>
        $("#logindata").hide();

    <%}
    else
    {%>
    $('#logindata').load("/Account/LogOn?returnUrl= <%:HttpContext.Current.Request.RawUrl%>"); 
    <%} %>
</script>

<%using (Html.BeginForm())
 { %>
<fieldset>
    <legend></legend>

     <div id="logindata" style="border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #CCCCCC;margin-bottom:10px;">
         **// I am loading the logon partial view here.**
     </div>


     <div class="editor-label">
        <%: Html.LabelFor(m => m.DeliveryInfo.Email)%>
     </div>
     <div class="editor-field">
        <%: Html.TextBoxFor(m => m.DeliveryInfo.Email)%>    
     </div>
     <div id="tohide">
     <div class="editor-label">
        <%: Html.LabelFor(m => m.DeliveryInfo.Password)%>
     </div>
     <div class="editor-field">
        <%: Html.PasswordFor(m=>m.DeliveryInfo.Password)%>    
     </div>
     <div class="editor-label">
        <%: Html.LabelFor(m => m.DeliveryInfo.ConfirmPassword)%>
     </div>
     <div class="editor-field">
        <%: Html.Password("ConfirmPassword")%>    
        <br />
        <%:Html.ValidationMessageFor(m=>m.DeliveryInfo.ConfirmPassword) %>
     </div>
     </div>
     <div class="editor-label">
        <%: Html.Label("Fullname")%>
     </div>
     <div class="editor-field">
        <%: Html.TextBoxFor(m => m.DeliveryInfo.Name)%>    
     </div>         
</fieldset>    
</div>
<%}%>

1 个答案:

答案 0 :(得分:0)

我可以在Partial视图中看到你的Html.BeginForm,但我看不到主视图的那个,所以我假设Html.BeginForm也覆盖了Partial视图,这总是会导致必要的字段被触发时按下提交按钮进行部分视图。

<div id="logindata" style="border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color:    
     #CCCCCC;margin-bottom:10px;">
     **// I am loading the logon partial view here.**
 </div>

<% using (Html.BeginForm("ActionMethod", "Controller"))
   { %>
     <div class="editor-label">
        <%: Html.LabelFor(m => m.DeliveryInfo.Email)%>
     </div>
     ......

 <%} %>
 </fieldset>