ASP.NET
  Home arrow ASP.NET arrow Page 2 - Event Handling with Atlas Client Controls
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

Event Handling with Atlas Client Controls
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2007-05-03

    Table of Contents:
  • Event Handling with Atlas Client Controls
  • Base Methods
  • Handling Control Events
  • Events for Lists

  • 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


    Event Handling with Atlas Client Controls - Base Methods


    (Page 2 of 4 )

    As discussed earlier in “Introducing Atlas Client Controls,” Atlas supports common methods for each control within Sys.UI. Most of these set some property that JavaScript exposes for all controls. Two examples of this are the get_accessKey()andset_accessKey()methods that control the DOMaccesskeyproperty.

    Methods with somewhat more visible results are those for controlling the CSS class of an element. This makes changing the layout of elements on the fly very easy. Here are the methods that are supported:

    get_cssClass()
       Reads the CSS class of an element

    set_cssClass()
       Sets the CSS class of an element

    addCssClass()
       Adds a CSS class to an element

    containsCssClass()
       Determines whether an element contains a CSS class

    removeCssClass()
       Removes one CSS class from an element

    toggleCssClass()
       Adds the class to an element if it is not already
       there; otherwise, removes the class

    Example 4-8 demonstrates thetoggleClassClass()method, which internally usesaddCssClass(),containsCssClass(), andremoveCssClass(). The example also uses theget_cssClass()method. In the page, the following three CSS classes are defined that can complement each other (i.e., every class covers another style).

      <style type="text/css">
      .style1 { font-family: Monospace; }
      .style2 { border-style: solid; }
      .style3 { color: #00f; }
      </style>

    The JavaScript code in the example selects one of these classes at random and then callstoggleCssClass(). ALabelcontrol periodically displays the current class or classes being used.

    Example 4-8. Using the base CSS methods for Atlas controls

    ControlCSS.aspx

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
     
    <title>Atlas</title>
      <style type="text/css">
      .style1 { font-family: Monospace; }
      .style2 { border-style: solid; }
      .style3 { color: #00f; }
      </style>

      <script language="JavaScript" type="text/javascript">
      function pageLoad() {
        window.setInterval(
         function() {
           var label = new Sys.UI.Label($("Label1"));
           var rnd = Math.ceil(3 * Math.random());
           label.toggleCssClass("style" + rnd);
           label.set_text(label.get_cssClass()); 
        
    },
        
    1000);
      }
      </script>

     

    </head>
    <body>
     
    <form id="form1" runat="server">
        <atlas:ScriptManager runat="server">
        </atlas:ScriptManager>
        <div>
         
    CSS class(es):
          <label id="Label1">
          </label>
       
    </div>
      
    </form>
    </body>
    </html>

    Figure 4-8 shows the result.

     


    Figure 4-8.  Two styles were applied at random

    More ASP.NET Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Programming Atlas," published by O'Reilly....
     

    Buy this book now. This article is excerpted from chapter four of the book Programming Atlas, written by Christian Wenz (O'Reilly, 2006; ISBN: 0596526725). Check it out today at your favorite bookstore. Buy this book now.

    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 3 hosted by Hostway
    Stay green...Green IT