Skip to content
Loading
How can I access html elements in MVC
2.Controller class Login action method code (WelcomeController)
public ActionResult Login()
{
return View();
}
[HttpPost]
public ActionResult Login()
{
string userName = Request.Form["txtUserName"];
string password = Request.Form["txtPassword"];
}
OR you can also try for below.
[HttpPost]
public ActionResult Login(FormCollection collection)
{
string userName = collection["txtUserName"];
string password = collection["txtPassword"];
}
Please Note this: this code is only for understanding purpose. It might be have error. hope you understood.
0