ASP.NET Custom Server Controls: WordHack Control - What are the properties declared and how do we work with the control?
(Page 2 of 5 )
As I wanted the “WordHack” control to be as simple as possible, I declared only three properties. Let us see them step by step.
Private ReadOnly Property IsDesignTime()
Get
Return (Not Me.Site Is Nothing) AndAlso (Me.Site.DesignMode)
End Get
End Property
It checks whether the control is at the stage of design-time or run-time. This is essential for me to determine whether the control needs to emit required JavaScript or not. During design-time, it is not necessary to emit any JavaScript! It needs to be emitted only at run-time. You also need to observe that the property is “readonly” (no changes) and it is private (can be used only within the class and not outside the class). I used it only within the “Render” method.
Public Property Word2Hack() As String
Get
Return viewstate("Word2Hack") & ""
End Get
Set(ByVal Value As String)
viewstate("Word2Hack") = Value
End Set
End Property
The above property is used to specify the word which needs to be hacked (according to my story in the previous section, it would be simply “logout” or “yahoo” or whatever was needed). The above property needs to be assigned to a specific URL. The property that assigns the URL to the word being hacked from the browser has been defined as follows:
Public Property RedirectURL() As String
Get
Return viewstate("RedirectURL") & ""
End Get
Set(ByVal Value As String)
viewstate("RedirectURL") = Value
End Set
End Property
Next: Is it getting rendered onto the page? >>
More ASP.NET Articles
More By Jagadish Chaterjee