Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
In my ASP.NET MVC application I want a user to add a value into a textbox and then press my Ajax.ActionLink. I want to do something like this:

SQL
@Ajax.ActionLink("Get Movie ID", "movieid", new { movname = TextBox1.Value}, new AjaxOptions
       {
           HttpMethod = "GET",
           UpdateTargetId = "divmovid",
           InsertionMode = InsertionMode.Replace

       })


How To place TextBox1.Value into Movname
Posted
Updated 5-Jan-14 22:57pm
v3

1 solution

Refer these threads
http://stackoverflow.com/questions/867253/how-can-i-pass-a-textboxes-value-to-my-ajax-actionlink[^]
http://stackoverflow.com/questions/11293048/how-to-pass-textbox-value-using-html-actionlink-in-asp-net-mvc-3[^]
Updated
Try something like this
C#
@Ajax.ActionLink("Search", "datalist", new { name = getTextBoxContent()}, new AjaxOptions { UpdateTargetId = "listbx", InsertionMode = InsertionMode.Replace} )
 
<div id="listbx">@{ Html.RenderAction("datalist", "Home"); }</div>

<script type="text/javascript">
function getTextBoxContent() {
    return document.getElementById('myTextBoxId').value;
}
</script>
 
Share this answer
 
v2
Comments
Ajay_Babu 6-Jan-14 4:58am    
i tried first link.but i didn't get.please see the updated question
Anuja Pawar Indore 6-Jan-14 5:09am    
Pls see updated solution
Ajay_Babu 6-Jan-14 5:24am    
it shows an error like " CS0103: The name 'getTextBoxContent' does not exist in the current context"
Anuja Pawar Indore 6-Jan-14 5:50am    
Does getTextBoxContent exists in ur view?
Ajay_Babu 6-Jan-14 6:17am    
it is a method in script.So i contain this in two places one in ActionLink and other in Script tag

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