In this example we pass value to the controller and then display it in View
Watch online:
in your controller receive some value (Name)
public ActionResult Index(string Name)
{
ViewBag.Message = HttpUtility.HtmlEncode("The name is: " + Name);
return View();
}
now, in view display that value (ViewBag.Message)
<p>@ViewBag.Message</p>
now if you navigate to Test page and provide it with some "Name" - the value will be displayed on the screen.
http://localhost:49771/Test?Name=Frank
No comments:
Post a Comment