Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created a texbox. When user give some input in the textbox and click the actionlink below, the value of the textbox will get pass to the actionResult(FWMenu) in the controller. I can not use html.begin form and submit button in the view. And i can not even use [httppost] in my controller. Is it possible in that way? If yes then please help me how. I have not used any class in model.

Below is my Controller.

C#
public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult FWMenu(string username)
        {
            return View();
        }

    }


This is my View.

HTML
<div>
    @Html.TextBox("txtUserName")
    @Html.ActionLink("Login", "FWMenu", new { username = @Html.TextBox("txtUserName") })
</div>
Posted

1 solution

Google "call mvc action from jquery" and you'll find lots of examples. Just make sure you have type:"GET" rather than type:"POST"

http://stackoverflow.com/questions/4120212/mvc-ajax-json-post-to-controller-action-method[^]

You'll need something to trigger your call, so either use a click event of a button or link, or use the blur event of the textbox if you want the call to be made when the user tabs away. google "jquery blur event input box" if you don't know how to attach code to element events.

To pre-empt your next question, no I won't write the code for you.
 
Share this answer
 

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