Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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" />

 }

and my controller is like

 public viewResult Searching(string name)
 {
   // bussiness logic
   return view();
 }
like image 272
yrahman Avatar asked Jul 26 '11 06:07

yrahman


1 Answers

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();
}
like image 194
Darin Dimitrov Avatar answered Sep 22 '22 20:09

Darin Dimitrov