ASP.NET
  Home arrow ASP.NET arrow Page 2 - Handling Articles and Categories for an AS...
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

Handling Articles and Categories for an ASP.NET AJAX Client-Centric Wiki Application
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2007-10-15

    Table of Contents:
  • Handling Articles and Categories for an ASP.NET AJAX Client-Centric Wiki Application
  • Display the Article Categories
  • Display an Article Asynchronously
  • Why is it More Challenging?

  • 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


    Handling Articles and Categories for an ASP.NET AJAX Client-Centric Wiki Application - Display the Article Categories


    (Page 2 of 4 )

    In fact, this part has already been shown at the right side of the homepage. And also, we know that when clicking an item under ‘Sections’ the user will be navigated to another page, namely ‘MsgList.aspx,’ which will show the more detailed article category information. In this section, we will continue to discuss it.

    First, let’s take a quick look at the design-time snapshot, as is shown in the following Figure 10.

    Figure 10—the design-time snapshot of page MsgList.aspx.

    You can see that only a few controls are put on the page: two HTML <a> elements (with each containing an <img> element) at the top and bottom respectively for the writer’s convenience, a MS AJAX ListView control occupying the larger middle space, and a line or footnote at the far bottom of the page.

    Note here that we have to combine the xml-script mode with the imperative JavaScript mode. There are two reasons for this. On the one hand, when the user clicks the hyperlink ‘Write a New Post’ we have to dynamically decide if he or she is a valid user so as to take the corresponding actions. On the other hand we have to dynamically load the DataSource that will be bound to the ListView control according to the different article category information the user has selected at the homepage.

    Now, let’s see the related code snippet. First, at the end of the xml-script part we define the following:

    <application load="onLoad">

    </application>

    Here we have not immediately called the load event of the data source ArtInfoDataSource when the application is loading but bound a client-side function onLoad to the load event of the Application object. A clever reader may have doped out that only in this way can we achieve our goal—dynamically loading the data source. The following gives the code for the onLoad function:

    function onLoad(sender,args)

    {

      g_ArtInfoDataSource= $find('ArtInfoDataSource');

       var paraCategoryID=getParm();

        if (paraCategoryID!=null) {

         g_ArtInfoDataSource.get_parameters()["CategoryID"] =paraCategoryID+1;

         g_ArtInfoDataSource.load();

     }

    }

      function getParm()

    {

      var url=this.location.href;

       var pageurl = url.substring(url.indexOf("=")+1);

      return parseInt(pageurl);

    }

    As you can see, we first ‘$find’ the data source control, then with a helper function named getParm we get the passed parameter (i.e. ‘CategoryID=x’) that is specified in the homepage, then we get and specify the exact value of the  CategoryID field of the data source, and at last we can succeed in loading our data source.

    As for the ‘Write a New Post’ hyperlink, it’s pretty easy. When you click the hyperlink, it calls the following function:

    function judge(){

    var bAuthenticated = <%= Page.User.Identity.IsAuthenticated.ToString().ToLower() %>;

      if (bAuthenticated){

       window.location.href='SendMsg.aspx';

    }

        else {window.location.href='login.aspx'; }

    }

    First, with the help of the special ASP.NET <% %> block, we can call the server-side method and get the related value to mark when the current user has been authenticated (note the current user related info is stored in the ASPNETDB.MDF database). If the user is a valid user, then we allow him to write a new post (i.e. article) by redirecting him to the SendMsg.aspx page; otherwise, we lead him back to the login page. 

    In the next section, we will start to look into another more interesting and challenging topic—displaying an article asynchronously.

    More ASP.NET Articles
    More By Xianzhong Zhu


     

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