0

我对 MVC 的 html 帮助程序有这个奇怪的问题,因为当我为 @Html.DropdownListFor 指定 @size 时,它​​会阻止 jquery .submit 与服务器通信。关于可能导致这种情况的任何想法?有没有其他方法可以让下拉菜单变高?这是代码:

           @using (Ajax.BeginForm("CreateInProgress", "Audit", new AjaxOptions {     
HttpMethod = "POST", OnSuccess = "CreateInProgressSuccess" }, new { id = "CreateInProgressMainForm"}))
           {
              <div id="reqTabContentBox" class="formPageContainer">
                  @Html.HiddenFor(x => x.ConfigDoc.CreateApproveButton.ConfigurableLabelDesc)
                  @Html.HiddenFor(x => x.ConfigDoc.CreateDisapproveButton.ConfigurableLabelDesc)
                  @Html.HiddenFor(x => x.ConfigDoc.CreateSaveButton.ConfigurableLabelDesc)
                  @Html.HiddenFor(x => x.ConfigDoc.CreateAdvanceButton.ConfigurableLabelDesc)

                  @Html.Partial("_CreateAudit")
               </div>
                       @Html.DropDownListFor(x => x.AuditDoc.AuditTemplateId, new SelectList(Model.AuditDoc.AuditTemplates, "Id", "Name"), new { size = "6", @class = "left" })
              <div id="finalButtons" class="formPageContainer">
                 <input id="AdvanceDirection" name="AuditDoc.AdvanceDirection" type="hidden" value="Forward" />

                  <span class="field-validation-error" id="CreateFormValidation"></span>  
                  <span class="field-validation-success" id="CreateSaveSuccess"></span> 
                  @if(Model.AuditDoc.CurrentStates.StateName == "Active")
                  {
                    <div class="btnContainer">
                       <input type="button" id="SaveCreateInProgress" class="toggleAllSelectors" value="@Model.ConfigDoc.CreateSaveButton.ConfigurableLabelDesc" />
                       <input type="button" id="AdvanceCreateInProgress" class="toggleAllSelectors" value="@Model.ConfigDoc.CreateAdvanceButton.ConfigurableLabelDesc" /> 
                    </div>
                  }
                  else
                  {
                    <label>@Model.ConfigDoc.AllEnterPrivateCommentLabel.ConfigurableLabelDesc</label> @Html.TextAreaFor(x => x.AuditDoc.PrivateComment, 0, 0, false)

                    <div class="btnContainer">
                       <input type="button" id="DisapproveCreateInProgress" class="toggleAllSelectors" value="@Model.ConfigDoc.CreateDisapproveButton.ConfigurableLabelDesc" @Model.OwnerApprovalAttribute />
                       <input type="button" id="ApproveCreateInProgress" class="toggleAllSelectors" value="@Model.ConfigDoc.CreateApproveButton.ConfigurableLabelDesc" @Model.OwnerApprovalAttribute />
                    </div>
                  }
               </div>
           }

这是jquery提交:

$("#CreateAuditMainForm").submit();

这是 Html dropdownlistfor helper 生成的代码:

<select class="left valid" data-val="true" data-val-number="The field AuditTemplateId must be a number." data-val-required="The AuditTemplateId field is required." id="AuditDoc_AuditTemplateId" name="AuditDoc.AuditTemplateId" size="6" style="display: block; "> ... </select>

我将不胜感激任何帮助或智慧之言!

4

1 回答 1

0

I don't know if this could be the reason of the problem, but by the HTML provided on the "select" field, it is not being closed. Maybe this is screwing the DOM structure, causing errors to submit the form on jquery. Try to edit the html and close the select field and retry the submit to see what happens.

<select class="left valid" data-val="true" data-val-number="The field AuditTemplateId must be a number." data-val-required="The AuditTemplateId field is required." id="AuditDoc_AuditTemplateId" name="AuditDoc.AuditTemplateId" size="6" style="display: block; " />

Let's see if we can have a lucky guess. :P

Regards.

于 2012-10-31T13:45:00.557 回答