ASP
  Home arrow ASP arrow Page 3 - Real Time Data Grid Part 2/2
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
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

Real Time Data Grid Part 2/2
By: Annette Tennison
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 11
    2002-02-08

    Table of Contents:
  • Real Time Data Grid Part 2/2
  • The JavaScript code
  • The JavaScript code (contd.)
  • The doDel JavaScript function
  • Using our DynamicGrid class
  • Conclusion

  • 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


    Real Time Data Grid Part 2/2 - The JavaScript code (contd.)


    (Page 3 of 6 )

    Our SendRemoteRequest JavaScript function creates a new instance of the MSXML2.XMLHTTP class, which allows us to retrieve the contents of any page on a HTTP web server (assuming that we have the permissions to do so). The strPage variable contains the URL to the page we want to retrieve. You'll notice that the strPage variable contains the URL of our dynamic.datagrid.asp page, as well as the variable of the query argument tacked onto the end.

    Next, we call the open method of our XMLHTTP object, and actually retrieve the requested page using its send method. We wont go into too much detail about the XMLHTTP library in this article, but if you'd like to read up on it, then checkout Mitchell's article on it here. The page being retrieved is our ASP script, but with a query string variable named "query" passed to it.

    At the top of our ASP script, before the declaration of our DynamicGrid class, we have the following lines:

    strQuery = Request.QueryString("query")



    If strQuery <> "" Then

    RunQuery(Server.HTMLEncode(strQuery))

    Response.End

    End If


    When we request this page using the XMLHTTP object through JavaScript, it sees that we have passed in a query string variable named query and calls the RunQuery method. The RunQuery method executes this query against our database and returns either true/false, indicating whether or not the query succeeded:

    objConn.Open strConnectionstring

    objComm.ActiveConnection = objConn

    objComm.CommandText = Query

    objComm.Execute



    If err.number = 0 And objConn.Errors.Count = 0 Then

    Response.Write "true"

    Else

    Response.Write "false"

    End If


    As soon as the RunQuery sub is finished, the Response.End method tells our XMLHTTP object that it has finished. We capture the output from this page using the responseText member of our XMLHTTP object and return it from our JavaScript function:

    return objXMLHTTP.responseText;

    Because our RunQuery ASP routine suppressed all error messages, the responseText method will only return the string "true" or "false". Jumping back to our doUpdate JavaScript function, we check the value returned from the call to the SendRemoteRequest function:

    blnSuccess = SendRemoteRequest(strQuery);



    if(blnSuccess == "true")

    {

    window.status = "Field '"+strFieldName+"' updated for record #"+(recordId+1)+" successfully.";

    setTimeout("window.status=''", 2000);

    }

    else

    {

    alert("An error occured while trying to update record.");

    }


    If it's "true", then the SendRemoteRequest function succeeded and updated our database successfully. We set the status text of the browser window to let the user know that record was updated, and use the setTimeout function to set the status text back to nothing after two seconds:

    Changing the window status text

    If the SendRemoteRequest function failed, then we display a message box telling the user that the record couldn't be updated:

    Shown when the update failed

    More ASP Articles
    More By Annette Tennison


     

    ASP ARTICLES

    - Central Scoreboard with Flash and ASP
    - Calorie Counter Using WAP and ASP
    - Creating PGP-Encrypted E-Mails Using ASP
    - Be My Guest in ASP
    - Session Replacement in ASP
    - Securing ASP Data Access Credentials Using t...
    - The Not So Ordinary Address Book
    - Adding and Displaying Data Easily via ASP an...
    - Sending Email From a Form in ASP
    - Adding Member Services in ASP
    - Removing Unconfirmed Members
    - Trapping HTTP 500.100 - Internal Server Error
    - So Many Rows, So Little Time! - Case Study
    - XDO: An XML Engine Class for Classic ASP
    - Credit Card Fraud Prevention Using ASP and C...







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