Js code:
<Script type = "text/javascript">
// <! [CDATA [
Function fLoadXml (url, show ){
// Var drp1 = document. getElementById ("TextBox1 ");
Var ClassID = "1"; // drp1.options [drp1.selectedIndex]. value;
Var oHttpReq = new ActiveXObject ("MSXML2.XMLHTTP ");
Var oDoc = new ActiveXObject ("microsoft. xmldom ");
OHttpReq. open ("POST", "data. aspx? ClassID = "+ ClassID, false );
//
// Call the page for reading small data categories.
// Pass the serial number value to the past
OHttpReq. send ("");
// Result = oHttpReq. responseText;
Switch (fCkDom2 ()){
Case 1:
Var xml = document. implementation. createDocument ('','', null );
Xml. onload = function () {show (xml, url );}
Xml. load (url );
Break;
Case 2:
Var xml = new ActiveXObject ('Microsoft. xmldom ');
Xml. onreadystatechange = function (){
If (xml. readyState = 4 ){
Show (xml, url );
}
}
Xml. load (url );
Break;
Default: document. write ('unknown ');
}
Function fCkDom2 (){
If (document. implementation & document. implementation. createDocument) return 1;
Else if (window. ActiveXObject) return 2;
Else return 0;
}
}
Function fShowXml (xml, url ){
// Var drp2 = document. getElementById ("TextBox1 ");
// Alert (drp2 );
// Alert ('OK ');
Var elements = xml. getElementsByTagName ('table ');
For (var I = 0; I <elements. length; I ++ ){
For (var j = 0; j <elements [I]. childNodes. length; j ++ ){
If (elements [I]. childNodes [j]. nodeType = 1 ){
Var eSub = elements [I]. childNodes [j]
Var content;
Try {
Content = eSub. firstChild. data; //. fontcolor ('blue ');
} Catch (e ){
Content = 'empty ';
}
// Assign the class name and number of the sub-class to DropDownList2
// Var newOption = document. createElement ("OPTION ");
// NewOption. text = content;
// NewOption. value = content;
// Drp2.options. add (newOption );
// Alert (content );
DIV1.innerHTML = content;
}
}
}
}
//]> Onload = "fLoadXml ('xml. xml', fShowXml);" onload = "fLoadXml ('xml. xml', fShowXml );"
</Script>
<Script language = "javascript">
Function getMessage ()
// Window. alert ("OK! ");
// Var timer = setInterval ("fLoadXml ('xml. xml', fShowXml);", 2000)
// Window. setTimeout ("opencontent ()", 5000 );
// Window. setTimeout ("fLoadXml ('xml. xml', fShowXml);", 1000); // run the command once in 1 second.
// Window. setInterval ("fLoadXml ('xml. xml', fShowXml);", 10000); // keep running every 5 seconds
// Window. onload = getMessage (); // onload = "getMessage ()"
{
Window. alert ("OK! ");
FLoadXml ("xml. xml", fShowXml );
}
// Var timer = setTimeout ("getMessage ()", 2000)
Window. setInterval ("getMessage ()", 10000 );
</Script>
Usage:
FLoadXml ("xml. xml", fShowXml) xml. xml is an xml
<Body onload = "getMessage ()">
DIV1 is the id of a div.
Data. aspx
Private void Page_Load (object sender, System. EventArgs e)
{
// Put user code to initialize the page here
SqlConnection con = new SqlConnection ("server = (local); uid = sa; pwd = breakin; database = E_Quotation ");
SqlDataAdapter da = new SqlDataAdapter ("select name from t where pid = '007 '", con );
DataSet ds = new DataSet ();
Da. Fill (ds );
Ds. WriteXml (Server. MapPath ("xml. xml "));
}