-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: LostWorld79
Message 2 in Discussion

  RegisterClientScriptBlock(key, script) (MSDN Extract) 
The RegisterClientScriptBlock method adds a block of client-side script after 
the Web Form's rendered <form> element, before any Web controls contained 
within the Web Form. The key input parameter allows you to specify a unique key 
associated with this script block, whereas the script parameter includes the 
complete script code to emit. (This script parameter should include the actual 
<script> element, along with the client-side JavaScript or Microsoft VBScript.) 
When emitting client-side script through the code-behind class of an ASP.NET 
Web page, typically the value of the key parameter isn't of paramount 
importance. Simply choose a descriptive key value. The key parameter is more 
pertinent when injecting client-side script code through a custom, compiled 
server control. There may be instances where a compiled control requires that 
there be a set of client-side functions. Multiple instances of the server 
control on one page might be able to share these common client-side script 
functions, so these functions need only be emitted once for the entire page, 
and not once per control instance. For example, the validation controls utilize 
client-side code to enhance the user experience. This client-side code must be 
present if there are any validation controls on the page, but if there are 
multiple validation controls, all can use this single set of shared functions. 
By giving a script block a key, a control developer building a control that 
utilizes a set of common client-side functions can check to see if the required 
set of common functions has already been added by another instance of the 
control on the page. If so, it need not re-add the common script. To check if a 
script block has been added with the same key, use the 
IsClientScriptBlockRegistered(key) method, which will return a Boolean value 
indicating whether or not a script block with the same key has been registered. 
Realize that you can add a script block without first checking if it's 
registered. If you attempt to add a script block with a key that's already 
registered, the added script block will be ignored and the original script 
block will remain assigned to that key. Note   The 
IsClientScriptBlockRegistered method is particularly useful in two situations. 
First, it comes in handy when you're adding similar, but unique script blocks, 
and you need to insure that each script block is given a unique key. The code 
we'll examine later on in this article illustrates the utility of the "is 
registered" method. A second use is when building a control that needs some 
common script, especially if the script is not trivially generated. By using 
the IsClientScriptBlockRegistered method, you can ensure that the script common 
to all instances of the server control on the page is generated only once per 
page load, rather than once per control instance on the page. 
The RegisterClientScriptBlock method is useful for adding client-side script 
that does not rely on any of the form fields present within the Web Form. A 
common use of this method is to display a client-side alert box. For example, 
imagine that you had a Web page with some TextBox Web controls and a Save 
Button. The TextBox controls might have particular values from a database. 
Imagine that this page allowed the user to modify these values and commit their 
changes by clicking the Save button. When clicking Save, the Web page would be 
posted back, and the Button's Click event would fire. You could create a 
server-side event handler for this event that updates the database. To let the 
user know that their changes had been saved, you might want to display an alert 
box that says, "Your changes have been saved." This could be accomplished by 
adding the following line of code to the Button's Click event 
handler:RegisterClientScriptBlock("showSaveMessage", _   "<script 
language=""JavaScript""> _       alert('Your changes have been saved.'); _    
</script>") See Also :RegisterStartupScript, RegisterArrayDeclaration, and 
RegisterHiddenFieldsFor More Information : 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/clientsidescript.asp

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to