ASP.NET
  Home arrow ASP.NET arrow Page 2 - 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 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
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

Atlas Client Controls
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2007-04-19

    Table of Contents:
  • Atlas Client Controls
  • Using Atlas Controls
  • Accessing HTML Elements
  • Labels

  • 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


    Atlas Client Controls - Using Atlas Controls


    (Page 2 of 4 )

    There are two concepts the Atlas framework uses with the controls in Sys.UI. Some of these controls provide JavaScript access to standard JavaScript methods. The others provide JavaScript access to HTML elements on the current page. Both ways are demonstrated in this section.

    Accessing JavaScript Methods

    One example of the first method is implemented by Sys.UI.Window. This implements a client-side message box. The JavaScript language supports three types of modal message boxes:

    window.alert()
       Message box with an OK button

    window.confirm()
       Message box with OK/Cancel or Yes/No buttons

    window.prompt()
       Message box with an input field and an OK button

    Inside the AtlasSys.UI.Windowclass, the functionality for callingwindow.alert()orwindow.confirm()is encapsulated in themessageBox()method. The default behavior is to present awindow.alert()box. This corresponds to the message box styleSys.UI.MessageBoxStyle.OK. The alternative is to use theSys.UI.MessageBoxStyle.OKCancelstyle, which useswindow.confirm()under the covers.

    But what about thewindow.prompt()window? For consistency with Visual Basic, this is implemented via theinputBox()method instead of themessageBox()method.

    The followingexample implements all three variants of client modal window. Three client-side buttons are in place for calling the Atlas functionality:

      <input type="button" value="MessageBoxOK" onclick="MessageBoxOKClick();" />
      <input type="button" value="MessageBoxOKCancel"
      onclick="MessageBoxOKCancelClick();" />
      <input type="button" value="InputBox" onclick="InputBoxClick();" />

    Each of the three functions—click1(),click2(), andclick3()—call an Atlas method, as shown in the following code:

      <script language="JavaScript" type="text/javascript">
      function MessageBoxOKClick() {
        Sys.UI.Window.messageBox("Using Sys.UI.Window");
      }

      function MessageBoxOKCancelClick() {
       
    Sys.UI.Window.messageBox("Using Sys.UI.Window", Sys.UI.MessageBoxStyle.  
      OKCancel);
      }

      function InputBoxClick() {
       
    Sys.UI.Window.inputBox("Using Sys.UI.Window", "<enter text here>");
      }
      </script>

    To use Atlas functionality in a page, you must include the Atlas library. The AtlasScriptManager element takes care of that:

      <atlas:ScriptManager runat="server"></atlas:ScriptManager>

    Example 4-1 shows the code you need for your first Atlas example in this chapter.

    Example 4-1. Modal JavaScript windows with Atlas

    ControlMessageBox.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>

      <script language="JavaScript" type="text/javascript">
      function MessageBoxOKClick() {
        Sys.UI.Window.messageBox("Using Sys.UI.Window");
      }

      function MessageBoxOKCancelClick() {
        Sys.UI.Window.messageBox("Using Sys.UI.Window", Sys.UI.MessageBoxStyle. OKCancel);
      }

      function InputBoxClick() {
       
    Sys.UI.Window.inputBox("Using Sys.UI.Window", "<enter text here>");
      }
      </script>

    </head>
    <body>
     
    <form id="form1" runat="server">
       
    <atlas:ScriptManager runat="server">
       
    </atlas:ScriptManager>
       
    <div>
         
    <input type="button" value="MessageBoxOK" onclick="MessageBoxOKClick();" /
    >
          <input type="button" value="MessageBoxOKCancel" onclick="MessageBoxOKCancelClick();" />
          <input type="button" value="InputBox" onclick="InputBoxClick();" />
        </div>
     
    </form>
    </body>
    </html>

    Figure 4-1 shows the result when you click the InputBox button.


    Figure 4-1.  Clicking a button opens a JavaScript window

    This is nice functionality, but not yet of real value, since only very basic JavaScript functionality is encapsulated by the Atlas controls you are using. However, there are other controls with actual real-world use.

    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

    - 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
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...
    - Back-end Management Tasks for an ASP.NET AJA...
    - User Information Management for an ASP.NET A...
    - Adding Comments and Search to an ASP.NET AJA...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway