Html.BeginForm()


1.        // 摘要:
         //     Writes an opening <form> tag to the response. When the user submits the form,
         //     the request will be processed by an action method.
         //
         // 參數:
         //   htmlHelper:
         //     此方法擴展的 HTML 幫助器實例。
         //
         // 返回結果:
         //     An opening <form> tag.
 
        public static MvcForm BeginForm(this HtmlHelper htmlHelper);
 



注:所有要提交的內容包括按鈕都必須在{ }內
 



2.      // 摘要:
         //     Writes an opening <form> tag to the response. When the user submits the form,
         //     the request will be processed by an action method.
         //
         // 參數:
         //   htmlHelper:
         //     此方法擴展的 HTML 幫助器實例。
         //
         //   actionName:
         //     操作方法的名稱。
         //
         //   controllerName:
         //     控制器的名稱。
         //
         //   method:
         //     用於處理窗體的 HTTP 方法(GET 或 POST)。
         //
         //   htmlAttributes:
         //     一個對象,其中包含要為該元素設置的 HTML 特性。
         //
         // 返回結果:
         //     An opening <form> tag.
         public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, object htmlAttributes);
 



EG:Html.BeginForm("actionName","controllerName",FormMethod.POST,new{@class="className"})
 



eg:@using (Html.BeginForm()) {
     <div >
         <fieldset>
             <div class="editor-label">
                 @Html.LabelFor(m => m.Account)
             </div>
             <div class="editor-field">
                 @Html.TextBoxFor(m => m.Account)
                 @Html.ValidationMessageFor(m => m.Account)
             </div>
 

            <div class="editor-label">
                 @Html.LabelFor(m => m.Password)
             </div>
             <div class="editor-field">
                 @Html.PasswordFor(m => m.Password)
                 @Html.ValidationMessageFor(m => m.Password)
             </div>
 

            <p>
                 <input type="submit" value="登錄"  />
             </p>
         </fieldset>
     </div>
 }
 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM