ASP.NET
  Home arrow ASP.NET arrow Page 2 - Completing an ASP.NET AJAX Server-Centric ...
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

Completing an ASP.NET AJAX Server-Centric Based Online Shopping Website
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2008-02-06

    Table of Contents:
  • Completing an ASP.NET AJAX Server-Centric Based Online Shopping Website
  • Ajaxifying the Operation Module
  • Notification Module
  • Customer/Supplier Functionality Module
  • Loading Foreground Functionality Modules

  • 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


    Completing an ASP.NET AJAX Server-Centric Based Online Shopping Website - Ajaxifying the Operation Module


    (Page 2 of 5 )

     

    Ajaxifying the Operation Module

    The foreground operation module is handled by using the "OperationUC.ascx" UserControl which is responsible for providing common operations to the users, such as logging in, registering, product searching and advanced searching, etc. Figure 40 gives the design-time snapshot of this control.


    Figure 40—the design-time snapshot for the foreground operation module


    First, substantially, an ASP.NET UserControlis very much like a Pageobject, with a great deal of properties and methods that are quite similar. Here, when users click the "Login" button, we’ll use UpdatePanel1to display the login-related information as well as gain the local update effect.

    Second, we’ve still used an ASP.NET AJAX Toolkit TextBoxWatermarkExtendercontrol to gain the watermark effect with the textbox control below the "Searching Keyword" label.

    Third, we’ve leveraged UpdatePanel2to enclose the area inside which lies an ASP.NET Panelcontrol which is used later to load one of the three modules (i.e. AdminOperationUC.ascx, CustomerOperationUC.ascx, and MyOperationUC.ascx) when the users log into the system to also gain the locally updated effect.

    Now, let’s take a look at the initialization of the control.

    protected void Page_Load(object sender, EventArgs e){

    if(Session["UserID"] != null && Session["RoleID"] != null){

    OperationPanel.Controls.Clear();

    if(Session["RoleID"].ToString() == "1") {

    OperationPanel.Controls.Add(Page.LoadControl
    ("~/UserControl/AdminOperationUC.ascx"));

    }

    if(Session["RoleID"].ToString() == "2") {

    OperationPanel.Controls.Add(Page.LoadControl
    ("~/UserControl/CustomerOperationUC.ascx"));

    }

    if(Session["RoleID"].ToString() == "3"){

    OperationPanel.Controls.Add(Page.LoadControl
    ("~/UserControl/MyOperationUC.ascx"));

    }

    }

    if (Session["UserName"] != null) {

    logged.Text = "Welcome:" + Session["UserName"].ToString();

    logged.Visible = true;

    unlogged.Visible = false;

    LogoutBtn.Visible = true;

    LoginBtn.Visible = false;

    }

    }

    As you can see from the code above, this function first judges whether the user has logged into the system, i.e. decides if the value of Session["UserID"]is empty. If the value of Session["UserID"]is not empty, then it means the user has already logged into the system. Therefore, the related module is loaded according to the different role of the user: if the role is "Super Administrator", the "AdminOperationUC.ascx" module is loaded, if it is "Supplier" then "CustomerOperationUC.ascx" and if "Common Customer" then "MyOperationUC.ascx."

    Here since all the buttons related to event handlers are simple to follow up, we will only take a short look at the ShowMessage helper function:

    private void ShowMessage(string sMsg){

    //Response.Write("<script>window.alert('" + sMsg + "')</script>");

    ScriptManager.RegisterStartupScript(Page, GetType(), "MyScript1",

    "alert('" + sMsg +"');", true);

    }

    This function is invoked in the above-mentioned buttons related to event handlers. And as has been discussed in the previous sections, the reason we’ve used the  RegisterStartupScript static member function of the ScriptManager controlinstead of "Response.Write(…)" is because using "Response.Write(…)" during the course of an asynchronous postback will lead to non-execution of the inner script or even a fatal script error.

    Next, let’s shift our attention to the notification module.

    More ASP.NET Articles
    More By Xianzhong Zhu


     

    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





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