Hi,
How do i update textbox using MVC Ajax UpdateTargetId option.?
I am new to MVC Ajax applications. Please any one help me out.
Thanks, Pon Kumar Pandian .T
Hi,
How do i update textbox using MVC Ajax UpdateTargetId option.?
I am new to MVC Ajax applications. Please any one help me out.
Thanks, Pon Kumar Pandian .T
You can simply wrap all you want to update in some div with id same that you're putting in UpdateTargetId property, and return new content(new textbox with new value). And also don't forget to set Ajax updating type to replace(not append).
We can't give the textbox control id directly in UpdateTargetId property. Bur we can do work around to achieve this. Please fine the blow mention code for the same.
//This the call back method once the ajax request has been successes.
function fnOnSuccess(context) {
alert(context); //this context having all the current ajax req & res information.
var response = context.get_data(); //Using this get_data() method we can get the response from server.
$('#txtajaxResponse')[0].value = response;
}
<%=Ajax.ActionLink("TextBox in UpdateTargetId","GetInfo","Ajax",new AjaxOptions{OnSuccess = "fnOnSuccess"}) %>
<%=Html.TextBox("txtajaxResponse")%>
Thanks, Pon Kumar Pandian .T