2016-08-05 22 views
0

Wenn Teilansicht Last in _Layout direkt, ich habe kein Problem in Client-Validierung habe und zeigt Feld, das durch eingereichte Fehler, aber als Aufruf Teilansicht genauso wie ein Teil der Indexseite:Client-Validierung in Teilansicht submiting

@Html.Partial("_CreateUser", Model) 
PartialView

_CreateUser:

@model ProjInMvc.Models.User 

<div id="update_panel"></div> 

    @using (Ajax.BeginForm("CreateUser", "Home",null, new AjaxOptions { UpdateTargetId = "update_panel", Url = "/Home/CreateUser", HttpMethod = "Post",InsertionMode =InsertionMode.Replace }, new { @class = "pull-right" })) 
    { 
    @Html.AntiForgeryToken() 
    <div class="form-horizontal"> 
    <hr /> 
    @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 

    <div class="form-group"> 
     @Html.LabelFor(model => model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" }) 
     <div class="col-md-10"> 
      @Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control" } }) 
      @Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" }) 
     </div> 
    </div> 
    <div class="form-group"> 
     @Html.LabelFor(model => model.LastName, htmlAttributes: new { @class = "control-label col-md-2" }) 
     <div class="col-md-10"> 
      @Html.EditorFor(model => model.LastName, new { htmlAttributes = new { @class = "form-control" } }) 
      @Html.ValidationMessageFor(model => model.LastName, "", new { @class = "text-danger" }) 
     </div> 
    </div> 

    <div class="form-group"> 
     @Html.LabelFor(model => model.UserName, htmlAttributes: new { @class = "control-label col-md-2" }) 
     <div class="col-md-10"> 
      @Html.EditorFor(model => model.UserName, new { htmlAttributes = new { @class = "form-control" } }) 
      @Html.ValidationMessageFor(model => model.UserName, "", new { @class = "text-danger" }) 
     </div> 
    </div> 

    <div class="form-group"> 
     <div class="col-md-offset-2 col-md-10"> 
      <input type="submit" value="Create" class="btn btn-default")" /> 
     </div> 
    </div> 
    </div> 
} 

Kann jemand mir helfen, dieses Problem zu verstehen? Tnx.

+1

es keinen Unterschied, ob seine in einem Layout oder der Hauptansicht macht. Laden Sie das Partial dynamisch, nachdem die Seite gerendert wurde (d. H. Mit Ajax)? –

+0

Ja, Teilansicht _CreateUser ist Ajax-Form. – aas

+0

Nein, ich meine, das Formular wird dynamisch geladen. Wenn ja, müssen Sie den $ .validator analysieren. –

Antwort

0

können Sie in Html.BeginForm nennen werden, Form in Form falsch ist, überprüfen Sie bitte, dass

+0

Danke, aber ich habe eine hier formulieren ?! – aas

+0

versuchen Sie, jquery Validierungspaket in 'Ajax.BeginForm' hinzuzufügen und geben Sie mir Feedback –