ASP.NET
  Home arrow ASP.NET arrow Page 3 - Finishing an ASP.NET AJAX-based Applicatio...
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

Finishing an ASP.NET AJAX-based Application
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 4
    2007-07-23

    Table of Contents:
  • Finishing an ASP.NET AJAX-based Application
  • Authoring the Web Service to Supply with Data
  • Adding the CascadingDropDown Control to the Web Page
  • Modifying the Related Contents in the CodeFile

  • 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


    Finishing an ASP.NET AJAX-based Application - Adding the CascadingDropDown Control to the Web Page


    (Page 3 of 4 )

    First, let's do some cleaning. Remove the two properties named AutoPostBack and OnSelectedIndexChanged from the two corresponding DropDownList controls. The following shows the code after modification:

     

    <asp:DropDownList ID="ddlCountry" Runat="server" >

    </asp:DropDownList>

    //omitted…

    <asp:DropDownList ID="ddlState" Runat="server">

    </asp:DropDownList>

     

    Second, let's add the two CascadingDropDown controls:

     

    <ajaxToolkit:CascadingDropDown ID="cddCountry" runat="server"

       TargetControlID="ddlCountry"

       Category="Country"

       PromptText="Please Choose a Country"

       LoadingText="Loading Countries..."

       ServicePath="../LocationService.asmx"

       ServiceMethod="GetCountries" />

    <ajaxToolkit:CascadingDropDown ID="cddCity" runat="server"

       TargetControlID="ddlState"

       Category="City"

       PromptText="Please Choose a State"

       LoadingText="Loading States..."

       ServicePath="../LocationService.asmx"

       ServiceMethod="GetStatesForCountry"

       ParentControlID="ddlCountry" />

     

    Let's take a close look at the first <ajaxToolkit:CascadingDropDown>. Note that its TargetControlID property is bound to the DropDownList "ddlCountry" and the Category is set to "Country" (please refer to the sentence "…kv["Country"]));" within the Web Method named GetStatesForCountry). And also, the ServicePath property is pointing to the Web Service we've just defined, and ServiceMethod is bound to the corresponding method named GetCountries, which indicates that the data source of this DropDownList comes from it. Similar things happen with the second <ajaxToolkit:CascadingDropDown>. However, the real secret that joins the two CascadingDropDowns together lies in the ParentControlID property of the second CascadingDropDown.

    Last but not least, according to the materials provided by MS AJAX framework, we have to disable the validate event of the related web page, or else there will be an "Invalid post back or callback argument" exception thrown during the post back of this page. Please refer to the following code in bold:

     

    <%@ Page Language="C#" EnableEventValidation="false" MasterPageFile="~/MasterPage.master" CodeFile="jobsearch.aspx.cs" Inherits="jobsearch_aspx" Title="Untitled Page" %>

     

    More ASP.NET Articles
    More By Xianzhong Zhu


       · I was looking for this since long time. Finally I find it. Great work. I am working...
     

    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