首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

MVC 后台获取参数解决思路

2012-02-07 
MVC 后台获取参数controllers 中我这么写C# code[HttpGet]public ActionResult Indexs(int id){string aa

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 />
<%}%>

热点排行