ASP.NET
  Home arrow ASP.NET arrow Page 3 - ASP.NET Custom Server Controls: Combining ...
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: Combining ImageHoverButton and RoundCorneredButton
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2005-10-31

    Table of Contents:
  • ASP.NET Custom Server Controls: Combining ImageHoverButton and RoundCorneredButton
  • Exposing properties for every side (including corners) of the button
  • Starting with the usual TABLE
  • Creating the header
  • Creating the body (content)
  • Closing the body (content) and creating the footer
  • How did I handle the post backs?
  • How is it different from my previous controls?

  • 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: Combining ImageHoverButton and RoundCorneredButton - Starting with the usual TABLE


    (Page 3 of 8 )

    The default “Render” method (when not overridden by us) usually calls “RenderBeginTag” before calling any other methods.  Let us examine the “RenderBeginTag” method in my control step by step:

    MyBase.AddAttributesToRender(writer)
           
    'registering JavaScripts
            If Not Page.IsStartupScriptRegistered(Me.ClientID &
    "_MouseOver")
    Then
                Page.RegisterStartupScript(Me.ClientID &
    "_MouseOver", getJS4MouseOver(Me.ClientID & "_MouseOver"))
           
    End If
            If Not Page.IsStartupScriptRegistered(Me.ClientID &
    "_MouseOut")
    Then
                Page.RegisterStartupScript(Me.ClientID & "_MouseOut",
    getJS4MouseOut(Me.ClientID & "_MouseOut"))
            End If

    Within the above method, I am trying to call the “MyBase.AddAttributesToRender(Writer)” statement to add any design-time attributes to my control.  This is a must when we use the control with the Visual Studio.NET designer.  You can also override with any other attributes you want (as shown in my previous articles of the same series).  The next two “if” structures will register two “hover” JavaScripts for the control.  Further proceeding, we have the following:

            'opening table
            writer.AddStyleAttribute("text-Align", "center")
            writer.AddStyleAttribute("vertical-Align", "middle")
            writer.AddStyleAttribute("cursor", "hand")
            writer.AddAttribute(HtmlTextWriterAttribute.Name,
    Me.UniqueID)
            writer.AddAttribute(HtmlTextWriterAttribute.Border,
    "0px")
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding,
    "0px")
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing,
    "0px")
            writer.AddAttribute("onMouseOver", Me.ClientID &
    "_MouseOver();")
            writer.AddAttribute("onMouseOut", Me.ClientID &
    "_MouseOut();")
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick,
    Page.GetPostBackEventReference(Me, String.Empty))
            writer.RenderBeginTag(HtmlTextWriterTag.Table)

    From all the above statements, the conclusion would be something like: I am trying to render a “<TABLE>” tag with some attributes. I am also emitting “javascript” events at this stage itself, which means that the “hover” event applies to the whole table!  Another of the most important statements to concentrate on from above is this: 

    writer.AddAttribute(HtmlTextWriterAttribute.Onclick,
    Page.GetPostBackEventReference(Me, String.Empty))

    That is the main trick I played to convert the “table” to “button.”  Once the above statement is executed, it now supports a post back when clicked!

    Starting simply with “<TABLE>” is not enough. We need to frame a 3x3 set of cells within the table.  I call the first row of cells header, second row of cells body (or content) and third row footer for a better understanding.

    In our next section, we shall see how to implement the header.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Another ASP.NET control...enjoy and give me the feedback
     

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - 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

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




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