ASP.NET
  Home arrow ASP.NET arrow Page 3 - ASP.NET Custom Server Controls: Cute ToolT...
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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: Cute ToolTip Control with Better Framework
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 18
    2005-11-07

    Table of Contents:
  • ASP.NET Custom Server Controls: Cute ToolTip Control with Better Framework
  • What are the properties declared and how do I work with the control?
  • How is it rendered?
  • JavaScripts: from custom control
  • JavaScripts: from IFrameBox.js
  • What is the ToolTip 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: Cute ToolTip Control with Better Framework - How is it rendered?


    (Page 3 of 6 )

    In my previous examples, I defined “RenderBeginTag”, “Render”, “RenderEndTag”  and several other methods of rendering.  In this scenario, as the control (tooltip) will not be displayed immediately after the web page gets rendered, certain methods are not used.

    Finally, I ended up overriding only two methods from the base class “webcontrol”.  They are as follows:

    • AddAttributesToRender
    • Render

    Even though it is not essential to use the “AddAttributesToRender” method in this case, I used it to separate the registration of JavaScript code from the “Render” method.  It is defined as follows:

    Protected Overrides Sub AddAttributesToRender(ByVal writer As
    System.Web.UI.HtmlTextWriter)
            MyBase.AddAttributesToRender(writer)
            'emit javascript only at run-time
            If Not IsDesignTime Then
                If Not Page.IsStartupScriptRegistered
    ("ToolTipFunctions") Then
                    Page.RegisterStartupScript("ToolTipFunctions", getJS4ToolTip())
                End If
            End If
        End Sub

    Within the above method, I am trying to call the “MyBase.AddAttributesToRender(Writer)” statement to add any design-time attributes to my control.  It is not  essential for this control in this scenario, but this is a must when we design interactive controls (as explained in my previous articles of the same series). 

    And you can even observe that I am using the “IsDesignTime” method here.  I would like to emit JavaScript code if, and only if, it is not design time in Visual Studio.NET.  I think you can understand the rest.  It's emitting JavaScript from a single function named “getJS4ToolTip” (which we will see in later sections).  Coming to the “Render” method, it is defined as follows:

    Protected Overrides Sub Render(ByVal writer As
    System.Web.UI.HtmlTextWriter)
            AddAttributesToRender(writer)
            writer.Write("<iframe id=""frIFrame"" name=""frIFrame""
    frameBorder=""0"" scrolling=""no"" ondrop=""return
    false;""></iframe>")
        End Sub

    The above method gets executed immediately when the control has to render itself.  The first statement tries to emit JavaScript code (if it is not design time).  Immediately after that, I am emitting an embedded IFRAME (not at all enclosed in DIV as stated in my previous article).  This emission of IFRAME is much simpler, when compared with the code available in my previous article for the same method.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hello....an improved version of Cute tooltip control released...have a look at it...
     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek