ASP.NET Custom Server Controls: Extended Wordhack Control with Key Combination
(Page 1 of 5 )
This article further extends my previous article on “WordHack control” (belonging to the same series) with a few more enhancements, together with a flexible and understandable approach to JavaScript code. It even introduces a new “CharacterHack” control to hack the keys with a “Ctrl” combination.
A downloadable file for this article is available
here.
The sample downloadable solution (zip) is entirely developed using Visual Studio.NET 2003 Enterprise Architect on Windows Server 2003 Standard Edition. But, I am confident that it would work with other versions of Windows (which support .NET 1.1) as well.
What are the new properties?
Since I already explained the “WordHack” control in my previous article, I don’t want to tell stories any more (as I injected a story of mine in my previous article). Coming straight to the point, the previous control works fine for only a single “WordHack.” But it doesn’t work for more than one “WordHack." You might also wonder “why don’t you support special keys (like combinations using the “Ctrl” key) within the WordHack?”
Before you ask those questions, I am enhancing the previous control with this new updated one, which supports any number of “WordHacks” in your web page. So, let us start with our new updated control.
Apart from some of the properties (like isDesignTime(), Word2Hack(), RedirectURL() and so on) in my previous article, I have added one more new property as follows:
Public Property OrderOfPreference() As String
Get
Return viewstate("OrderOfPreference") & ""
End Get
Set(ByVal Value As String)
viewstate("OrderOfPreference") = Value
End Set
End Property
The above is the main important property which is used to maintain an “Order of Preference” (something like a serial number starting from 0). Why is this property necessary? If we want to hack three words, which one comes first? That is why I use the “OrderOfPreference” property.
The “OrderOfPreference” for the first control (or instance) should always be 0 and contine increasing (with the only interval being one) for each new instance of the same control, if they are on the same web page. This creates an index of all words (or characters) to be hacked, and I conquer them in JavaScript.
Next: Did any Attributes change from the previous article? >>
More ASP.NET Articles
More By Jagadish Chaterjee