ASP.NET
  Home arrow ASP.NET arrow Page 4 - ASP.NET Custom Server Controls: WordHack C...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

ASP.NET Custom Server Controls: WordHack Control
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2005-11-14

    Table of Contents:
  • ASP.NET Custom Server Controls: WordHack Control
  • What are the properties declared and how do we work with the control?
  • Is it getting rendered onto the page?
  • JavaScripts: the heart of WordHack
  • What is the WordHack Designer class?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    ASP.NET Custom Server Controls: WordHack Control - JavaScripts: the heart of WordHack


    (Page 4 of 5 )

    Until now, we have seen only the ASP.NET custom control code, but didn’t go through the JavaScript code at all.  Now we shall go through the method “getJS4WordHack”.

           If Me.Word2Hack.Trim = "" Then
                Return ""
            End If

            Dim js As String
            js = "<SCRIPT LANGUAGE=""JavaScript"">"

            js &= "var SpecialWord = '" & Me.Word2Hack.Trim & "',"
            js &= "SpecialUrl = '" & Me.RedirectURL.Trim & "',"
            js &= "SpecialLetter = 0;"
            js &= "function getKey(keyStroke) {"
            js &= "var isNetscape=(document.layers);"
            js &= "var eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;"
            js &= "var which = String.fromCharCode(eventChooser).toLowerCase();"
            js &= "if (which == SpecialWord.charAt(SpecialLetter)) {"
            js &= "SpecialLetter++;"
            js &= "if (SpecialLetter == SpecialWord.length) window.location = SpecialUrl;"
            js &= "}"
            js &= "else SpecialLetter = 0;"
            js &= "}"
            js &= "document.onkeypress = getKey;"
            js &= "</script>"
            Return js

    First of all (from the above code), I am checking whether there exists any “Word2Hack” which has been provided or not.  If it is not provided, I simply skip the JavaScript (because there exists nothing to really hack).  Once the “Word2Hack” property is assigned to a word (something like “logout”), the JavaScript gets emitted.  The above JavaScript mainly captures any key press using the “onkeypress” event of the “document” object.  Once any key gets pressed, it executes the “getKey” function which actually checks to see whether the successive key we pressed matches up with “Word2Hack” or not.  If so, we immediately redirect it to the value available in the property “RedirectURL”.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hai guys...this is another contribution of mine as part of ASP.NET controls...have a...
       · The demo is very good, but if I put two wordhecks there, the second doesn't work....
       · Hello, I think, I addressed those issues in the next article "ASP.NET Custom Server...
     

    ASP.NET ARTICLES

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT