Code
<% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Default. aspx. CS " Inherits = " _ Default " %>
<!Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head Runat = "Server" >
< Title > </ Title >
</ Head >
< Body >
< Script Type = "Text/JavaScript" Language = "JavaScript" >
VaR XMLHTTP = Null ; // Define the XMLHttpRequest
Window. onload = Function (){
Loadxmlhttp ();
Sendrequest ( " Welcome.htm " );
}
// Returns the XMLHTTPRequest object of different browsers.
Function Loadxmlhttp (){
If (Window. XMLHttpRequest ){
XMLHTTP = New XMLHttpRequest ();
} Else If (Window. activexobject ){
Try {
XMLHTTP = New Activexobject ( " Microsoft. XMLHTTP " ); // IE6, ie5
} Catch (E ){}
}
}
// Send request
Function Sendrequest (URL ){
If (XMLHTTP ){
XMLHTTP. Open ( " Get " , URL, True );
XMLHTTP. onreadystatechange = Oncallback; // Function
XMLHTTP. setRequestHeader ( ' Content-Type ' , ' Application/X-WWW-form-urlencoded ' );
XMLHTTP. Send ( Null );
}
}
Function Oncallback (){
If (XMLHTTP. readystate = 4 ){
If (XMLHTTP. Status = 200 ){
VaR R = Document. getelementbyid ( ' Results ' );
R. innerhtml = XMLHTTP. responsetext;
} Else {
Alert ( ' Error: ' + XMLHTTP. status );
}
}
}
</ Script >
< Form ID = "Form1" Runat = "Server" >
< Div >
< Span ID = "Results" > </ Span >
</ Div >
</ Form >
</ Body >
</ Html >