Here is my scenario
@Html.Textbox("value")
how to pass above text box value to below action link
@Html.ActionLink("Search","Search",new {firstname=value)
Here is my scenario
@Html.Textbox("value")
how to pass above text box value to below action link
@Html.ActionLink("Search","Search",new {firstname=value)
You can do it using javascript. First generate the anchor tag with a href having a faked value of firstname:
<a href="@Url.Action("Search", "Controller", new {firstname="xxxx"}") id="lnk">Search</a>
Also, generate the with an ID (i.e. txtSearch).
Then, using javascript you can attach the click event of this . Using jQuery code will be something like:
$("#lnk").click(function(evt) {
var fakedUri = $("#lnk").prop("href");
var uri = fakedUri.replace("xxxx", $("#txtSearch").val());
});
Greetings!
You need to use a form
<form method="post" action="@Url.Action("Search", "Search")">
@Html.Textbox("value")
</form>