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" />
}
and 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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With