<!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>
<title>测试</title>
<script type="text/javascript">
var xmlhttp;
function getSubmodule()
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("get","Rss_SubModule.aspx",true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = ShowList;
xmlhttp.send(null);
}
function ShowList()
{
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
doc = new ActiveXObject("Msxml2.DOMDocument")
doc.loadXML(xmlhttp.responseText);
var items = doc.getElementsByTagName("SubModule");
var s = document.getElementById("Select1");
for(var i= 0;i < items.length;i++)
{
var op = document.createElement("option");
op.value = items[i].getElementsByTagName("SubModuleID")[0].firstChild.nodeValue;
var tx = document.createTextNode(items[i].getElementsByTagName("SubModuleName")[0].firstChild.nodeValue);
op.appendChild(tx);
s.appendChild(op);
}
}
else
{
alert(xmlhttp.status +" : "+ xmlhttp.statusText);
}
}
}
function displayText()
{
for(var i=0 ;i< document.getElementById("Select1").options.length;i++)
{
if(document.getElementById("Select1").options[i].selected)
{
alert(document.getElementById("Select1").options[i].value);
}
}
}
</script>
</head>
<body>
<input id="Button1" type="button" value="button" onclick="getSubmodule()" />
<select id="Select1" onchange="displayText()">
</select>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>测试</title>
<script type="text/javascript">
var xmlhttp;
function getSubmodule()
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("get","Rss_SubModule.aspx",true);
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp.onreadystatechange = ShowList;
xmlhttp.send(null);
}
function ShowList()
{
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
doc = new ActiveXObject("Msxml2.DOMDocument")
doc.loadXML(xmlhttp.responseText);
var items = doc.getElementsByTagName("SubModule");
var s = document.getElementById("Select1");
for(var i= 0;i < items.length;i++)
{
var op = document.createElement("option");
op.value = items[i].getElementsByTagName("SubModuleID")[0].firstChild.nodeValue;
var tx = document.createTextNode(items[i].getElementsByTagName("SubModuleName")[0].firstChild.nodeValue);
op.appendChild(tx);
s.appendChild(op);
}
}
else
{
alert(xmlhttp.status +" : "+ xmlhttp.statusText);
}
}
}
function displayText()
{
for(var i=0 ;i< document.getElementById("Select1").options.length;i++)
{
if(document.getElementById("Select1").options[i].selected)
{
alert(document.getElementById("Select1").options[i].value);
}
}
}
</script>
</head>
<body>
<input id="Button1" type="button" value="button" onclick="getSubmodule()" />
<select id="Select1" onchange="displayText()">
</select>
</body>
</html>
Rss_SubModule.aspx
using System;
using System.Data;
using System.Text;
using System.Xml;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Rss_SubModule : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
();
xml.PutSubModule();
}
private void PutSubModule()
{
SubModule sub = new SubModule();
DataSet ds = sub.GetSubModule();
XmlTextWriter w = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
w.WriteStartDocument();
w.WriteStartElement("GetSubModule");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
w.WriteStartElement("SubModule");
w.WriteElementString("SubModuleID", ds.Tables[0].Rows[i][0].ToString());
w.WriteElementString("SubModuleName", ds.Tables[0].Rows[i][1].ToString());
w.WriteEndElement();
}
w.WriteEndElement();
w.WriteEndDocument();
ds.Dispose();
w.Close();
}
}
using System.Data;
using System.Text;
using System.Xml;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Rss_SubModule : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
();
xml.PutSubModule();
}
private void PutSubModule()
{
SubModule sub = new SubModule();
DataSet ds = sub.GetSubModule();
XmlTextWriter w = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);
w.WriteStartDocument();
w.WriteStartElement("GetSubModule");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
w.WriteStartElement("SubModule");
w.WriteElementString("SubModuleID", ds.Tables[0].Rows[i][0].ToString());
w.WriteElementString("SubModuleName", ds.Tables[0].Rows[i][1].ToString());
w.WriteEndElement();
}
w.WriteEndElement();
w.WriteEndDocument();
ds.Dispose();
w.Close();
}
}