2012-09-04 105 views
0

我试图通过cliecking查看按钮来将视图页面重定向到另一个查看页面。 防爆,通过点击具有查询字符串的提示按钮在mvc4中重定向到一个模型到另一个模型

我有两个页面 1.学生 2. BookIssue

我有过滤StudentName。在这个viewPage中,我有一个文本框和一个提交按钮。当我点击提交按钮时,它应该带我到BookIssue控制器与输入文本框中的studentName。

我必须TempData的获得在其他模型中的价值,但本人认为不好的做法,在代码中使用这个

请帮我在这个问题上。

回答

0

在罗村尝试RedirectToAction结果与studentName参数

public ActionResult Student(string studentName) 
{ 
    //... 
    return RedirectToAction("index", "BookIssue", new { studentName }); 
} 

然后在BookIssueController收到studentName

您也可以通过键入action名称,并在学生页的形式controller名重定向

@using (Html.BeginForm("index", "BookIssue")) 
{ 
    @Html.TextBox("StudentName") 
    <input type="submit" name="Go to Book Issue"/> 
} 
相关问题