2012-10-09 71 views
1

不存在在調試過程中,我的MVC模式和的FormCollection是空白的,沒有價值的火狐(15)或Chrome(最新版本)。所有的模型和的FormCollection值都爲空,空的,或者Firefox或Chrome

在使用IE(9),我可以看到這些值就好調試。

你知道這個解決方案是什麼嗎?對於面向公衆的網站來說,這些瀏覽器無法進行任何編程,這一點非常嚴重。

這是我的看法......

@model PDFConverterModel.ViewModels.ViewModelTemplate_Guarantors 

@{ 
    ViewBag.Title = "BHG :: PDF Generator"; 
} 
<h2>@ViewBag.Message</h2> 

<div> 

    <table style="width: 1000px"> 
     <tr> 
      <td colspan="5"> 
       <img alt="BHG Logo" src="~/Images/logo.gif" /> 
      </td> 
     </tr> 

     @using (Html.BeginForm("ProcessForm", "Home", FormMethod.Post)) 
     { 
      <tr> 
       <td> 
       @(Html.Kendo().IntegerTextBox() 
         .Name("LoanID") 
         .Placeholder("Enter Loan ID") 
       ) 
      </tr> 
      <tr> 
       <td>@Html.LabelFor(model => model.LoanType) 
        @Html.DisplayFor(model => model.LoanType) 
       </td> 
       <td> 
        <label for="ddlDept">Department:</label> 
        @(Html.Kendo().DropDownList() 
          .Name("ddlDept") 
          .DataTextField("DepartmentName") 
          .DataValueField("DepartmentID") 
          .Events(e => e.Change("Refresh")) 
          .DataSource(source => 
          { 
           source.Read(read => 
           { 
            read.Action("GetDepartments", "Home"); 
           }); 
          }) 
        ) 
       </td> 
      </tr> 

      if (Model.ShowGeneratePDFBtn == true) 
      { 
       if (Model.ErrorT == string.Empty) 
       { 
      <tr> 
       <td colspan="5"> 
        <u><b>@Html.Label("Templates:")</b></u> 
       </td> 
      </tr> 
      <tr> 
       @for (int i = 0; i < Model.Templates.Count; i++) 
       { 
        <td> 
         @Html.CheckBoxFor(model => Model.Templates[i].IsChecked) 
         @Html.DisplayFor(model => Model.Templates[i].TemplateId) 
        </td> 
       } 

      </tr> 
       } 
       else 
       { 
      <tr> 
       <td> 
        <b>@Html.DisplayFor(model => Model.ErrorT)</b> 
       </td> 
      </tr> 
       } 

       if (Model.ErrorG == string.Empty) 
       { 
      <tr> 
       <td colspan="5"> 
        <u><b>@Html.Label("Guarantors:")</b></u> 
       </td> 
      </tr> 
      <tr> 
       @for (int i = 0; i < Model.Guarantors.Count; i++) 
       { 
        <td> 
         @Html.CheckBoxFor(model => Model.Guarantors[i].isChecked) 
         @Html.DisplayFor(model => Model.Guarantors[i].GuarantorFirstName)&nbsp;@Html.DisplayFor(model => Model.Guarantors[i].GuarantorLastName) 
        </td> 
       } 

      </tr> 
       } 
       else 
       { 
      <tr> 
       <td> 
        <b>@Html.DisplayFor(model => Model.ErrorG)</b> 
       </td> 
      </tr> 
       } 
      } 
      <tr> 
       <td colspan="3"> 
        <input type="submit" name="submitbutton" id="btnRefresh" value='Refresh' /> 
       </td> 
       @if (Model.ShowGeneratePDFBtn == true) 
       { 
        <td> 
         <input type="submit" name="submitbutton" id="btnGeneratePDF" value='Generate PDF' /> 
        </td> 
       } 
      </tr> 
      <tr> 
       <td colspan="5"> 
        @Model.Error 
       </td> 
      </tr> 
     } 
    </table> 

</div> 

<script type="text/javascript"> 

    $('btnRefresh').on('click', '#btnRefresh', function() { 
     Refresh(); 
    }); 

    function Refresh() { 

     var LoanID = $("#LoanID").val(); 

     if (LoanID != "") { 
      document.forms[0].submit(); 
     } 
     else { 
      alert("Please enter a LoanId"); 
     } 
    } 
</script> 
+0

BTW,我使用mvc4 – sagesky36

回答

0

我剛剛發現的問題是什麼experimneting。

的Telerik的MVC小部件不發出任何的FormCollection數據!!!!

只有EditorFor和TextBoxFor發射這些值,加上輸入按鈕。

有什麼好處是這些小部件,如果我無法從他們使用的FormCollection值????特別是DropDownList,我可以重新調用數據,並需要將選定的值傳遞給其他方法。

1

我知道這是一個非常古老的問題,但回答這可能幫助人們喜歡誰是這個問題掙扎。

我有類似的問題。問題就出在這裏:

<table style="width: 1000px"> 
     <tr> 
      <td colspan="5"> 
       <img alt="BHG Logo" src="~/Images/logo.gif" /> 
      </td> 
     </tr> 

     @using (Html.BeginForm("ProcessForm", "Home", FormMethod.Post)) 
     { 
      <tr> 
      <td> 
       @(Html.Kendo().IntegerTextBox() 
         .Name("LoanID") 
         .Placeholder("Enter Loan ID") 
       ) 
      </td> 
      </tr> 
     } 
</table> 

開始表格後有直接<tr>標籤!像chrome和mozilla這樣的瀏覽器在這種情況下會感到困惑。 <table>標籤應位於表單內。如果我們看看您的代碼,這正是我所做的,<table>標籤在@using Html.BeginForm之前。 Internet Explorer以某種方式理解這一點,但其他瀏覽器不知道。

當我做了一個檢查元素,我發現每個<tr>標記中都有一個表單標記,並且它始終將FormCollection作爲null返回。在表單中簡單定義<table>解決了我的問題。

所以這裏就應該是這樣:

<table style="width: 1000px"> 
      <tr> 
       <td colspan="5"> 
        <img alt="BHG Logo" src="~/Images/logo.gif" /> 
       </td> 
      </tr> 
      <tr><td> 
      @using (Html.BeginForm("ProcessForm", "Home", FormMethod.Post)) 
      { 
      <table> 
       <tr> 
       <td> 
        @(Html.Kendo().IntegerTextBox() 
          .Name("LoanID") 
          .Placeholder("Enter Loan ID") 
        ) 
       </td> 
       </tr> 
      </table> 
      } 
      </td></tr> 
</table>