MVC3 两个页面之间怎么传值?

做一个添加的页面,在页面中有个TextBox,点击后跳出新页面,里面列出可以选择的值,选中后将值传回原来的添加界面,请问怎么将新页面中选择的值加入到原页面的TextBox中?

,在action里写句return("你想返回的页面");这样便可以获得同名的model.X了.或者也可以赋值给TempView["x"],再在返回页的action里取值:table.x=TempView["x"];居然直接就学MVC3, 一步到位吲.
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-07-15
我用的MVC2可以这样操作,你试试吧。Submit.aspx写入字符串,跳转到Index.aspx显示出来;。。。。。。。。。。。。。。。。。 public ActionResult Index(string name)
{
TempData["name"] = name;
return View();
}
public ActionResult Submit()
{
return View();
}。。。。。。。。。。。。。。。。。 <h2>Index</h2>
<%=Html.TextBox("name",TempData["name"])%>。。。。。。。。。。。。。。。。。。 <h2>Submit</h2>
<% using (Html.BeginForm("Index","Test",FormMethod.Post)) { %>
<%:Html.TextBox("name") %>
<input type="submit" value="登录" />
<% } %>
第2个回答  推荐于2018-03-29
Submit.aspx写入字符串,跳转到Index.aspx显示出来;。。。。。。。。。。。。。。。。。 public ActionResult Index(string name)
{
TempData["name"] = name;
return View();
}
public ActionResult Submit()
{
return View();
}。。。。。。。。。。。。。。。。。 <h2>Index</h2>
<%=Html.TextBox("name",TempData["name"])%>。。。。。。。。。。。。。。。。。。 <h2>Submit</h2>
<% using (Html.BeginForm("Index","Test",FormMethod.Post)) { %>
<%:Html.TextBox("name") %>
<input type="submit" value="登录" />
<% } %>本回答被网友采纳
相似回答