读书人

MVC 后台获取参数解决思路

发布时间: 2012-02-07 17:45:36 作者: rapoo

MVC 后台获取参数
controllers 中我这么写

C# code
   [HttpGet]        public ActionResult Indexs(int id)        {            string aa = Request["userName"];            string bb = aa + id.ToString();            return View();        }

然后前台我这么写
C# code
    <%: Html.TextBox("userName")%>    <%: Html.ActionLink("测试", "Indexs", new { id=1 })%> 

现在问题是我再调试的时候 string aa = Request["userName"]; 这里的值是null
请问下我如何修改才能得到这个值?谢谢了。。。。。

[解决办法]
<%using(Html.BeginForm("测试", "Indexs",FormMethod.Get)){%>
<%=Html.TextBox("userName",userName)%>
<input type=submit />
<%}%>

读书人网 >asp.net

热点推荐