Class ClientScriptProxy

This is a proxy object for the Page.ClientScript and MS Ajax ScriptManager object that can operate when MS Ajax when present otherwise falling back to Page.ClientScript. Because MS Ajax may not be available accessing the methods directly is not possible and we are required to indirectly reference client script methods through this class.

This class should be invoked at the Control's start up and be used to replace all calls Page.ClientScript. Scriptmanager calls are made through Reflection indirectly so there's no dependency on the script manager.

This class also provides a few additional page injection helpers like the abillity to load scripts in the page header (rather than in the body) and to use script compression using wwScriptCompressionModule without using MS Ajax.


public class ClientScriptProxy : object

Class Members

GetClientScriptResourceUrl Works like GetWebResourceUrl but can be used with javascript resources to allow using of resource compression (if the module is loaded).
public string GetClientScriptResourceUrl( Control control,
Type type,
string resourceName );
GetWebResourceUrl Returns a WebResource URL for non script resources
public string GetWebResourceUrl( Control control,
Type type,
string resourceName );
IsMsAjax Checks to see if MS Ajax is registered with the current Web application.
public static bool IsMsAjax();
IsScriptManagerOnPage Checks to see if a script manager is on the page
public bool IsScriptManagerOnPage( Page page );
RegisterClientScriptBlock Registers a client script block in the page.
public void RegisterClientScriptBlock( Control control,
Type type,
string key,
string script,
bool addScriptTags );
RegisterClientScriptInclude Registers a script include tag into the page for an external script url
public void RegisterClientScriptInclude( Control control,
Type type,
string key,
string url );
RegisterClientScriptIncludeInHeader Registers a client script reference in the header instead of inside the document before the form tag.
public void RegisterClientScriptIncludeInHeader( Control control,
Type type,
string Url,
string comment );
RegisterClientScriptResource Returns a WebResource or ScriptResource URL for script resources that are to be embedded as script includes.
public void RegisterClientScriptResource( Control control,
Type type,
string resourceName );
RegisterClientScriptResourceInHeader Inserts a client script resource into the Html header of the page rather than into the body as RegisterClientScriptInclude does.
public void RegisterClientScriptResourceInHeader( Control control,
Type type,
string resourceName,
string comment );
RegisterHiddenField Injects a hidden field into the page
public void RegisterHiddenField( Control control,
string hiddenFieldName,
string hiddenFieldInitialValue );
RegisterStartupScript Registers a startup code snippet that gets placed at the bottom of the page
public void RegisterStartupScript( Control control,
Type type,
string key,
string script,
bool addStartupTags );
Current Current instance of this class which should always be used to access this object. There are no public constructors to ensure the reference is used as a Singleton to further ensure that all scripts are written to the same clientscript manager.


Namespace: Westwind.Web.Controls
Assembly: westwind.ajaxtoolkit.dll

  Last Updated: 7/8/2008 | © West Wind Technologies, 2008