I have button. I want to route new view when i clicked the button. The button is like below:
If you wants to refresh page:
Controller:
public ActionResult Index()
{
return View();
}
public ViewResult Test()
{
ViewBag.Name = Request["txtName"];
return View();
}
Index.cshtml:
@using (Html.BeginForm("Test", "Home", FormMethod.Post ))
{
}
Test.cshtml:
@ViewBag.Name
=============================================
If you don't wants to refresh page:
Controller:
public ActionResult Index()
{
return View();
}
[HttpPost]
public PartialViewResult TestAjax(string Name)
{
ViewBag.Name = Name;
return PartialView();
}
Index.cshtml:
TestAjax.cshtml:
@ViewBag.Name