I have the following inputs in my View and I want to pass them to the controller:
<div>
<span><label>Username</label></span>
<span><input type="text" class="textbox" id="username"></span>
</div>
<div>
<span><label>Password</label></span>
<span><input type="password" class="password" id="password"></span>
</div>
And this is my controller method in order to authenticate a particular user:
public ActionResult LoginMethod(string username, string password)
{
if (username == "admin" && password == "admin1")
{
return RedirectToAction("Home");
}
else
{
return RedirectToAction("Login");
}
}
nameattributes which match your property names. But you should be using a model and using strongly typed html helpers to bind to your model, and post back the model. Go to the MVC site and learn the basics.