Go4Expert (http://www.go4expert.com/)
-   ASP (http://www.go4expert.com/articles/asp-tutorials/)
-   -   AJAX Implementation in ASP 3.0 (http://www.go4expert.com/articles/ajax-implementation-asp-30-t18328/)

naimish 3Jul2009 15:28

AJAX Implementation in ASP 3.0


To implement AJAX in ASP 3.0.


This is a simple application illustrating how AJAX can be implemented in ASP 3.0.

The code

HTML Code:

  <title>Sample AJAX in ASP  </title>
  <script language="javascript">
  var XMLHTTPReq;
  // This is the function that makes an AJAX request to the Server side scripting written in ASP 3.0
  // This function can be enhanced to incorporate any changes to suit any business logic and can
  // be successfully implemented.
  function CheckName()
    var strEmpName = document.all.EmpName.value;
    /* The link to the server side scripting */
    var strURL = "SampleSrv.asp?EmpName=" + strEmpName;
    /* Important: This line initiates the httprequest variable */
    if (window.ActiveXObject) {
    XMLHTTPReq = new ActiveXObject("Microsoft.XMLHTTP");
    /* Important: This segment makes a request to the server */
    if (XMLHTTPReq)
    XMLHTTPReq.open("POST", strURL, false);
    var strResults = XMLHTTPReq.responseText;
    /* The result that is received from the previous segment is used here */
    if (strResults.toLowerCase() == "true") //true. indicating record exists in Database
    alert("This login already exists. Try another name.");
    document.all.EmpName.selected = true;
    //Everything is cool and can proceed with getting the rest of the details.
  <table cellspacing=0 cellpadding=3 border=1>
  <tr><td colspan=2><CENTER><B>Enter your Login Details</B></CENTER></td></tr>
  <tr><td>Login:</td><td><input type="Text" name="EmpName" value="" onblur="CheckName();"></td></tr>
  <tr><td>Password:</td><td><input type="Text" name="pwd" value=""></td></tr>
  <tr><td>Re-enter Password:</td><td><input type="Text" name="pwd1" value=""></td></tr>
  <tr><td>Qualification:</td><td><input type="Text" name="Qualif" value=""></td></tr>
  <tr><td>Address:</td><td><input type="Text" name="Add" value=""></td></tr>
  <tr><td>City:</td><td><input type="Text" name="City" value=""></td></tr>
  <tr><td>Country:</td><td><input type="Text" name="Country" value=""></td></tr>
  <tr><td colspan=2></td></tr>
  <tr><td colspan=2 align=center><input type="button" value="Submit" onclick="alert('Non-functional!')"></td></tr>

LenoxFinlay 13Jul2009 17:12

Re: AJAX Implementation in ASP 3.0
You've heard of it. It is the latest buzz term for web programmers these days. AJAX is an acronym that stands for Asynchronous JavaScript and XML. AJAX gains its popularity by allowing data on a page to be dynamically updated without having to make the browser reload the page. I will describe more about how AJAX works, and then go into some sample code to try out.
This term has been made famous by some of Google's latest web apps. At the top of this list is Google Suggest, which gives you suggestions (go figure) on what you are searching for as you type based on popularity of the search term. If you aren't familiar with Google Suggest, check it out.

shabbir 3Aug2009 14:34

Re: AJAX Implementation in ASP 3.0
Nominate this article for Article of the month - Jul 2009

All times are GMT +5.5. The time now is 22:44.