ASP.NET
  Home arrow ASP.NET arrow Adding Comments and Search to an ASP.NET A...
Iron Speed
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 
Download TestComplete 
Windows Web Hosting
 
IBMฎ developerWorks 
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

Adding Comments and Search to an ASP.NET AJAX Server-Centric Based Online Shopping Website
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-01-02

    Table of Contents:
  • Adding Comments and Search to an ASP.NET AJAX Server-Centric Based Online Shopping Website
  • Leaving Words
  • Advanced Search
  • Advanced Search continued

  • 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

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Adding Comments and Search to an ASP.NET AJAX Server-Centric Based Online Shopping Website
    (Page 1 of 4 )

    In real scenarios, an online shopping city must support the users to make free comments on the goods as well as leave suggestions to help the city owners to further improve their services. In this example in the sixth part of an eleven-part series, we have simulated these functionalities. We also set up the search functions.
    A downloadable .rar file is available for this article.

    Making comments on the Products

    This function is performed through the "comment.aspx" page. Let’s take a quick look at the related design-time snapshot, as illustrated in the following Figure 19.


    Figure 19—the design-time snapshot for making comments

    Apparently, this is a simple yet representative design concerning the ASP.NET AJAX server-centric pages. At the top lies the ScriptManager controlto schedule the relations between ASP.NET and the MS AJAX framework itself. The middle part is a GridView circled by the UpdatePanel controlto gain the partial update effect as the GridView control changes its contents. The lower part is two TextBox controls for the user to populate with his comments. At the bottom are two buttons: "Submit my comment" for submitting the comment and "Close" for closing the current browser window.

    There are two points here worth pointing out. First, we purposely omit the utilization of ASP.NET AJAX server control namedUpdateProgessand the ASP.NET AJAX Control Toolkit Extender control namedUpdatePanelAnimation,both here and in the rest of this sample, partially to save  writing time. Second, despite the scope of the UpdatePanel controlwe can still not securely use the sentence we mentioned earlier: ‘Response.Write(“<script>…</script>”);’.

    Now, let’s omit the analysis of binding data to the GridView "CommentView," but leave room for submitting the comment. Clicking the "Submit my comment" button will trigger the SureBtn_Click event handler. The following shows the related code:

    protected void SureBtn_Click(object sender,EventArgs e){

    if(Session["UserID"] == null) {

    ScriptManager.RegisterStartupScript(up1, typeof(UpdatePanel),
    "ScriptName1", "alert('Not logged in. Please login first!')", true);

    return;

    }

    Comment comment = new Comment();

    comment.AddComment(Desn.Text,Body.Text,nProductID,Int32.Parse(Session
    ["UserID"].ToString()));

    ///rebind data

    BindCommentData(nProductID);

    }

    protected void ReturnBtn_Click(object sender,EventArgs e){

    Response.Write("<script>window.close();</script>");

    }

    Note here in the SureBtn_Click function, we still use the static method named RegisterStartupScriptof ScriptManagerto report to the user an error message instead of using the ‘Response.Write(“<script>…</script>”);’sentence, or else you will surely meet the error shown in the following Figure 20.


    Figure 20—the typical error message when ‘Response.Write(…)’ conflicts with UpdatePanel

    In contrast, in the event handler for the "ReturnBtn" button, we have used ‘Response.Write("<script>window.close();</script>");’. To our astonishment, there is nothing wrong and the page closes in the normal way. Why? According to the result of my simple study, if you use ‘Response.Write()’to directly write JavaScript functions such as alert()to the page during the course of a asynchronous postback, these functions often do not run as expected and even result in some error. Therefore, in the first function above if we use ‘Response.Write()’ instead of ‘ScriptManager.RegisterStartupScript(…)’, then the asynchronous postback action triggered by the subsequent sentences will of course lead to the error in Figure 20. However, in the second function, there is only one simple sentence ‘Response.Write()’, this of course will not result in an error occurring.

    More ASP.NET Articles
    More By Xianzhong Zhu


     

    ASP.NET ARTICLES

    - 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...
    - Order-Related Modules for an ASP.NET AJAX Se...
    - User and Role Management for an ASP.NET AJAX...
    - Programming an ASP.NET AJAX Server-Centric B...
    - Tables and Relationships for an ASP.NET AJAX...
    - Building an ASP.NET AJAX Server-Centric Base...
    - Finishing an Introductory Look at CIL
    - An Introduction to CIL

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




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