RegisterClientScriptBlock within AJAX method call RegisterClientScriptBlock within AJAX method call asp.net asp.net

RegisterClientScriptBlock within AJAX method call


With AJAX enabled pages, you should use the ScriptManager to register scripts:

ScriptManager.RegisterClientScriptBlock(Page, typeof(MyPage),     "MyScript", "GoStuff()", true)

You can use this to register all your scripts (Original load, postback, AJAX postback).


It works if you specify the UpdatePanel being updated on the AJAX call back. For example:

ScriptManager.RegisterClientScriptBlock(UpdatePanelMain, typeof(UpdatePanel),   UpdatePanelMain.ClientID,   "document.getElementById('imgLoading').style.display = 'none';" +   "document.getElementById('divMultiView').style.display = 'inline';",   true);

The control in the first argument must be inside the update panel or the update panel itself that triggers the update.


As far as I know for this you would be forced to be calling this method via a PostBack and not an ajax call. There may be OTHER ways of doing this, but it is not possible with Page.ClientScript....