Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I trying to Search a given list according to give "SearchKey". I have multiple buttons on my form, So to handle this i have used "ActionNameSelectorAttribute". But after using it, Value of SearchBox is not passed in ActionResult Method.

        [MultiButton(MatchFormKey = "action", MatchFormValue = "Search")]
        public ActionResult Serach(string SearchKey)
            ProjectUtility OProjectUtility = new ProjectUtility();
            IEnumerable<Project> obj = OProjectUtility.SearchByKey(SearchKey);
            return View(obj);

the "SearchKey" value is null.

On View I have TextBox and a button.

Please help!

1 solution

I think you cant get the textbox value directly,can use Formcollection class, in this class you will get value of all the controls present on form.

       public ActionResult Edit(int id, FormCollection collection)
           using (LoginModelDataContext objLoginModelDataContext = new LoginModelDataContext())
               string Isupdate = collection["ckbStatus"];
               if (Isupdate == "true,false")


               var recordToUpdate = objLoginModelDataContext.GoalDetails.Single(m => m.Id == id);
               if (ModelState.IsValid)
                   return RedirectToAction("Index");
               return View(recordToUpdate);


In this code i am getting the value of checkbox,in the same way you can get the value of textbox.
hope this will help
Share this answer
Vi(ky 21-Oct-13 8:28am    
Thank You! Gitanjali
It's Worked
Gitanjali Singh 21-Oct-13 8:31am    
Welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900