這是我的視圖。在提交表單MVC時獲取控制器上DropDown的值
@using (Html.BeginForm("uploadimage",
"PatientDocumentsMain",
FormMethod.Post,
new { @Area = "PatientDocument", enctype =
"multipart/form-data" }))
{
<table cellspacing="0" cellpadding="0" class="table table-
striped">
<tr>
<td>
Document Name:<span class="spnError">*</span>
</td>
<td>
<input type="text" id="txtDocumentName" name="DocName"
class="required form-control" />
</td>
</tr>
<tr>
<td class="tdEditDoc">
<span>Document Type:</span><span class="spnError">*</span>
</td>
<td id="tdDocumentCategory">
@Html.DropDownList("ddlDocumentCategory", null, new { @id = "",
@onchange = "AddCategory();", @class =
"required form-control", @name= "DocType" })
</td>
</tr>
<tr>
<td class="tdEditDoc">
<span>Date:</span><span class="spnError">*</span>
</td>
<td>
<input type="text" id="txtPatientDocumentDate" class="Date
required IsDate form-control" name="DocDate" />
</td>
</tr>
<tr>
<td class="tdEditDoc" style="height: 25px;">
<span>Confidental:</span>
</td>
<td>
<input type="checkbox" id="chkPatientDocumentIsConfedential"
/>
</td>
</tr>
<tr>
<td class="tdEditDoc" style="vertical-align: top">
Comments:
</td>
<td>
<textarea id="txtPatientDocumentComments" name="comments"
style="margin-right: 15px; width: 245px; height: 69px;
border-width: 1px; border-color: #c4c4c4;resize:none"
class="form-control">
</textarea>
</td>
</tr>
</table>
<input type="file" name="file" id="file" title="Upload file(s)" />
}
我提交這份表格到該控制器
public void uploadimage(string DocName, string DocType, string DocDate, string d, string comments, HttpPostedFileBase file)
{
}
我得到不同的下拉value.Plus所有其它參數我怎樣才能得到複選框的值(選中與否)。我沒有使用任何模型,並希望沒有它。
你爲什麼您的文章actionMethod內創造了這麼多變量的名字,我會建議使用FormValues或模型。 –
不能使用模型。我怎樣才能使用FormValues? –
將ActionMethod中的參數替換爲 'public void uploadImage(FormCollection fomr)...'它是一個鍵/值字典。 –