how to send text box value as parameter on form submit in mvc3 asp.net
i have created partial view in MVC3. now i want to send text box value as parameter of form submit on pressing the submit button
my partial view is like
@using (Html.BeginForm("Searching", "AccountManager", FormMethod.Post, new { name ="Wat should i put here" }))
{
<input id="account" type="text" class="s" />
<input id="Search" type="submit" class="b" value="hi" />
}
a开发者_高级运维nd my controller is like
public viewResult Searching(string name)
{
// bussiness logic
return view();
}
Simply give your textbox the same name as your action parameter argument:
@using (Html.BeginForm("Searching", "AccountManager")
{
<input id="account" type="text" name="name" class="s" />
<input id="Search" type="submit" class="b" value="hi" />
}
Now inside your controller action you will get the value entered by the user:
public ActionResult Searching(string name)
{
// bussiness logic
return View();
}
精彩评论