Hi,
This is an example of RegisterClientScriptBlock
Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "key","scriptblock", True)
Why do the method needs the type as the first parameter ?
Thanks.
Hi,
This is an example of RegisterClientScriptBlock
Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "key","scriptblock", True)
Why do the method needs the type as the first parameter ?
Thanks.
From the MSDN docs: "A client script is uniquely identified by its key and its type. Scripts with the same key and type are considered duplicates."
Basically it gives you an additional way to uniquely identify your scripts. You could have the same key value across different types of controls.
I've wondered about this myself. As far as I can see in Reflector, it's not used by RegisterClientScriptBlock() directly, it is only passed through to be used by the GetHashCode() method of the ScriptKey class. There it probably serves to uniquely identify the script block further beyond just the user-supplied key, since it is linked to the specified type.