我有一个场景,我希望将一个值“选项卡”从一个操作带到它的视图,然后从视图到另一个操作。我已将选项卡值放在要在视图中访问的 viewdata 中。请建议我如何在视图中访问此“选项卡”值,然后将其转发到“身份验证”操作。
我正在开发 mvc3 2010。下面是我的代码:
public ActionResult Index(string tab)
{
try
{
ViewData["tab"] = tab;
return View("Authorize");
}
catch (Exception ex)
{
return View("EmptySearch");
}
}
@using (Html.BeginForm("Authenticate", "Authorization"))
{
<div>
<fieldset>
<legend>User Information</legend>
<div class="editor-label">
@Html.Label("Password")
@Html.TextBox("password")
@Html.ValidationMessageFor(m => m.password)
</div>
<p>
<input type="submit" value="Submit" />
</p>
</fieldset>
</div>
}
[AcceptVerbs("POST")]
public ActionResult Authenticate(FormCollection collection)
{
try
{
string password = collection["password"];
password = password.Trim();
//ViewData["BatchNumber"] = password;
//dynamicsContext.CommandTimeout = 180;
//List<BatchMember> batchMemberList =
// Queries.compiledBatchQuery(dynamicsContext, password).ToList<BatchMember>();
return RedirectToAction("Index", "GreatPlains");
}
catch (Exception ex)
{
return View("EmptySearch");
}
}