Programming Microsoft ASP.NET 4 - Dino Esposito [105]
Script-Related Methods
Table 5-13 enumerates all the methods in the Page class related to HTML and script code to be inserted in the client page.
Table 5-13. Script-Related Methods
Method
Description
GetCallbackEventReference
Obtains a reference to a client-side function that, when invoked, initiates a client callback to server-side events.
GetPostBackClientEvent
Calls into GetCallbackEventReference.
GetPostBackClientHyperlink
Appends javascript: to the beginning of the return string received from GetPostBackEventReference. For example:
javascript:__doPostBack(‘CtllD’,’’)
GetPostBackEventReference
Returns the prototype of the client-side script function that causes, when invoked, a postback. It takes a Control and an argument, and it returns a string like this:
__doPostBack(‘CtlID’,’’)
IsClientScriptBlockRegistered
Determines whether the specified client script is registered with the page. It’s marked as obsolete.
IsStartupScriptRegistered
Determines whether the specified client startup script is registered with the page. It’s marked as obsolete.
RegisterArrayDeclaration
Use this method to add an ECMAScript array to the client page. This method accepts the name of the array and a string that will be used verbatim as the body of the array. For example, if you call the method with arguments such as theArray and “’a’, ‘b’”, you get the following JavaScript code:
var theArray = new Array(‘a’, ‘b’);
It’s marked as obsolete.
RegisterClientScriptBlock
An ASP.NET page uses this method to emit client-side script blocks in the client page just after the opening tag of the HTML