views:

215

answers:

1

May be this simple. But, I've hard time figuring it out.

I've a controller with different actions that calls the DB code and return result. I want to pass the value of text box to different actions in controller.

How to do it? I know that, I can pass values by using form. But, I don't to know how to call different actions in controller from single view.

A: 

I'm not sure what language or framework you're using, but in ASP.NET MVC input control IDs map onto action parameters so if you've got a text box:

<input type="text" name="firstName" id="firstName/>

Then when that form is posted to your action, the framework passes the value of the textbox from the POST data by matching it with the action parameter:

public ActionResult UpdateUser(string firstName)
{
  User user = UserManager.UpdateUser(this.CurrentUserId, firstName);
  return View(user);
}
Charlie
Sorry. I'm using MVC. If I use form, then I'm not sure how to call different action from the same view.
sam26092004

related questions