How to get input value or javascript variable in Asp.Net MVC Ajax.ActionLink

Posted by achu on Stack Overflow See other posts from Stack Overflow or by achu
Published on 2009-04-12T23:41:13Z Indexed on 2010/04/16 2:33 UTC
Read the original article Hit count: 1269

Filed under:
|

I want to pass an input control value (say textbox1.value or a javascript variable) to a controller action method (as a parameter) without a form post (using Ajax.ActionLink). please see the code below

is it possible to assign like new {name = textbox1.value} in Ajax.ActionLink.

View

<input type="text" id="textbox1" />
<% =Ajax.ActionLink("mylink", "linkfunction", new {name = textbox1.value}, new AjaxOptions { UpdateTargetId = "result"})%>
<span id="result"></span>

and controler action is ..
public string linkfunction(string name)
{
    return  DateTime.Now.ToString();
}

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc