MVC:View向Controller传值并处理页面跳转

本文介绍了在MVC框架中如何从View层通过HTML表单向Controller层传递数据,并详细说明了如何指定ActionName和ControllerName以实现数据提交。在Controller的对应Action中进行数据处理后,讨论了如何执行页面跳转操作。

参考资料:https://blog.youkuaiyun.com/fly043488/article/details/70169287

View中html:

Html.BeginForm("ActionName","ControllerName",FormMethod.method)

ActionName:要处理这次submit提交数据的后台Action(函数)名

ControllerName:要处理这次submit提交数据的后台controller(控制器)名

            <div>
                @using (Html.BeginForm("Register", "Login", FormMethod.Post))
                {
                    <table>
                        <tr>
                            <td class="td1">*&nbsp;&nbsp;</td>
                            <td><input type="text" class="form-control" name="mailbox" placeholder="邮箱" /></td>
                        </tr>
                        <tr><td><br /></td></tr>
                        <tr>
                            <td class="td1">*</td>
                            <td><input type="text" class="form-control" name="name" placeholder="用户名" /></td>
                        </tr>
                    </table>
                    <br />
                    <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
                    <input type="submit" class="btn btn-primary" value="发送验证码" />
                }
                
            </div>

Controller(LoginController)中c#:

        public ActionResult Register(FormCollection form)
        {
            return RedirectToAction("LoginView4", "Login");
        }

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值