1

In the sample code below, I have ajax action-link sending out a GET request. I want to send the value of Message text-box as query string for the request. I know this can be done with ajax-forms. But I was wondering if there's anything I can put in the place of XXXXX in the code below to achieve this.

<div>@Html.TextBoxFor(m => m.Message)</div>
<div>
    @Ajax.ActionLink("Click here for ajax call", "AjaxPartial", 
        new { message = XXXXX },
        new AjaxOptions() {
            UpdateTargetId = "ajaxLoadedSection",
            InsertionMode = InsertionMode.Replace,
            HttpMethod = "Get",
        })
</div>
<div id="ajaxLoadedSection"></div>
achhetri
  • 11
  • 2
  • No, because razor code is parsed on the server before its sent to the view, so you the value could only ever be the initial value of `Message` (not the edited value). You could possibly handle the `OnBegin` ajax option to update the route value –  Mar 24 '15 at 02:46
  • @StephenMuecke thanks for your response... I found info on how to use OnBegin to update route values [here](http://stackoverflow.com/questions/7334309/dynamic-ajax-actionlink-routevalues) – achhetri Mar 24 '15 at 05:56
  • This should answer your question http://stackoverflow.com/questions/867253/how-can-i-pass-a-textboxes-value-to-my-ajax-actionlink – Yogesh lele Mar 26 '15 at 11:38

0 Answers0