ASP.NET Custom Server Controls: Extended Wordhack Control with Key Combination - Did any Attributes change from the previous article?
(Page 2 of 5 )
Yes. The “AddAttributesToRender” method is a bit different from my previous article, since now it has to register two JavaScripts (rather than a single one, as in my previous article). Let us examine the following script.
Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)
MyBase.AddAttributesToRender(writer)
'emit javascript only at run-time
If Not IsDesignTime Then
'mouse events
If Not Page.IsStartupScriptRegistered("WordHack") Then
Page.RegisterStartupScript("WordHack", getJS4WordHack())
End If
If Not Page.IsStartupScriptRegistered(Me.ClientID &
"_WordParam") Then
Page.RegisterStartupScript(Me.ClientID & "_WordParam", getJS4WordParam())
End If
End If
End Sub
If you carefully observe, “getJS4WordHack” will be common for all controls (or instances) and gets emitted only once, but “getJS4WordParam” will be different for each instance (which we will see in later sections) and gets emitted differently for each instance. The “Render” method will be identical to that of the one I mentioned in my previous article, which calls the above “AddAttributesToRender” method.
Next: Did any JavaScripts change from the previous article? >>
More ASP.NET Articles
More By Jagadish Chaterjee