5

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();
 }

1 Answer 1

16

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();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.