MVC中BeginForm的用法

一、常用形式

Html.BeginForm(actionName,controllerName,method,htmlAttributes){}

 

二、参数说明

actionName:操作方法的名称,System.String。

controllerName:控制器的名称,System.String。

method:用于处理窗体的 HTTP 方法(GET 或 POST),System.Web.Mvc.FormMethod。
 

htmlAttributes:一个对象,其中包含要为该元素设置的 HTML 特性,System.Object。


三、BeginForm实例

 

<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


转载于:https://my.oschina.net/u/2428791/blog/644351

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值