ASP.NET
  Home arrow ASP.NET arrow Page 4 - Delving Deeper into Drag and Drop Programm...
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

Delving Deeper into Drag and Drop Programming in Microsoft ASP.NET AJAX
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-06-25

    Table of Contents:
  • Delving Deeper into Drag and Drop Programming in Microsoft ASP.NET AJAX
  • Write a Behavior: ShoppingCartBehavior to make the shopping cart droppable
  • Coding the web page
  • Obtaining the list of the pets to sell via Web Service
  • Dealing with the order via Web Service

  • 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


    Delving Deeper into Drag and Drop Programming in Microsoft ASP.NET AJAX - Obtaining the list of the pets to sell via Web Service


    (Page 4 of 5 )

    In this sample, after the client side has been initialized, we will invoke the server-side Web Service asynchronously to acquire the information about all the pets on the online store, as well as add a ShoppingCartBehavior action to the shopping cart, all of which should be performed within the pageLoad function (this function is a global built-in function defined by MS AJAX, which is automatically executed after the client-side framework has been initialized successfully, within which we can perform some initializations).

     

    function pageLoad(sender, args) {

      // call Web Service to get all the pets related info

      ShoppingService.GetPets(onPetsGot);

     

      // add behavior ShoppingCartBehavior to the shopping cart

      $create(

        ShoppingCartNamespace.ShoppingCartBehavior,

        {"name": "myShoppingCartBehavior"},

        null,

        null,

        $get("shoppingCart")

      );

    }

    Here, inside the call back function onPetsGot(), we'll, according to the pet set returned from the web service, create each element corresponding to the pets within the container dynamically. And also, we should add the  DraggableProductBehavior behavior to each element inside the container-petContainer.

     

    function onPetsGot(result) {

      // first get the container to display all the pets

      var petContainer = $get("petContainer");

     

      // iterate through the pet collection returned from the server

      for (var index = 0; index < result.length; ++ index) {

        // current pet

        var thisPet = result[index];

     

        //Create a new DOM element-div according to current pet info, and add it to the pet container

        var petElem = document.createElement("div");

        petElem.innerHTML = thisPet.Name + " "+thisPet.Category+ " " +thisPet.Color+ " "+" - $: "

           + thisPet.Price;

        petContainer.appendChild(petElem);

     

        //add behavior DraggableProductBehavior to this product (this pet info)

        $create(

          ShoppingCartNamespace.DraggableProductBehavior,

          {"pet": thisPet}, // Set property 'pet'

          null,

          null,

          petElem

        );

      }

    }

     

    More ASP.NET Articles
    More By Xianzhong Zhu


       · Whats ironic is I just recently created a drag/drop DLL control or a customer and...
       · Hi, I'm very glad to hear that and would like to be notified. In fact, the current...
       · Hey guys, many tnx for the examples - beginners like me can get the right impuls to...
       · Thanks a lot for showing the path to ajax - specials.Latawiec
       · You're welcome. Remember that I'm just a newbie for MS AJAX (only for 6 months in...
     

    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