1、經常使用形式javascript
Html.BeginForm(actionName,controllerName,method,htmlAttributes){}html
2、參數說明java
actionName:操做方法的名稱,System.String。app
controllerName:控制器的名稱,System.String。spa
method:用於處理窗體的 HTTP 方法(GET 或 POST),System.Web.Mvc.FormMethod。
code
htmlAttributes:一個對象,其中包含要爲該元素設置的 HTML 特性,System.Object。orm
3、BeginForm實例htm
<h1>在線申請</h1> @using (Html.BeginForm("Apply", "Star", FormMethod.Post, new {@class="MyForm"})) { <div class="application_b_3"> <table width="820" border="0"> <tr> <td width="80" height="50">達人類型</td> <td width="730"> @Html.DropDownListFor(m => m.StarModel.TypeID, Model.DropList, new { id = "type", @class = "my-" }) </td> </tr> <tr> <td height="50">首頁達人照</td> <td> <div class="picture_an" id="UploadPhoto" style="width: 142px"> <a href="javascript:void(0);" class="btn_addPic"><span><em>+</em>上傳照片</span> <input tabindex="3" title="支持jpg、jpeg、gif、png格式,文件小於5M" size="3" name="pic" id="absFileInput" class="filePrew" type="file" /> </a> </div> </td> </tr> <tr> <td height="50"></td> <td> @Html.HiddenFor(m => m.StarModel.UserGravatar, new { id = "SXtPhoto" }) <img src="" id="imgPhoto" height="176px" /> </td> </tr> <tr> <td height="100">自薦理由</td> <td> @Html.TextAreaFor(m => m.StarModel.ApplyReason, new { id = "tDesc" }) </td> </tr> <tr> <td height="50"></td> <td> <a href=" javascript:void(0)" id="btnApplication"><img src="@Url.Content("~/Areas/SNS/Themes/Default/Content/images/ap_9.gif")" alt="" /></a> </td> </tr> </table> </div> }
參考資料:MVC中BeginForm的用法 http://www.studyofnet.com/news/1175.html對象