blog.mha.dk
The on-line blog of Michael Holm Andersen

Access ScriptManager on Content Page

Monday, 5 November 2007 10:44 by mha

Often you need to access the ScriptManager on a Content Page to e.g. set Focus to a Button. The easiest way to do this is using the static GetCurrent method of the ScriptManager Class. Like this:

ScriptManager.GetCurrent(Page).SetFocus(btnSubmitRequest);

Unless you're really sure a ScriptManager exists, you have to check if it exists like this:

// Does a ScriptManager exists for the page?
ScriptManager scMan = ScriptManager.GetCurrent(Page);
if (scMan == null) throw new Exception("No ScriptManager found!");

Comments are closed