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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek