1.建立一ASPx頁面,Html代碼
<Html>
<HEAD>
<title>WebForm1</title>
<SCRIPT language="Javascript">
//城市------------------------------
function cityResult()
{
var city=document.getElementById("TextBox1");
WebForm1.GetCityList(city.value,get_city_Result_CallBack);
}
function get_city_Result_CallBack(response)
{
if (response.value != null)
{
//debugger;
document.getElementById("DropDownList1").style.display="block";
document.getElementById("DropDownList1").length=0;
var ds = response.value;
if(ds != null && typeof(ds) == "object" && ds.Tables != null)
{
for(var i=0; i<ds.Tables[0].Rows.length; i++)
{
var name=ds.Tables[0].Rows[i].city;
var id=ds.Tables[0].Rows[i].cityID;
document.getElementById("DropDownList1").options.add(new Option(name,id));
}
}
}
else
{
document.getElementById("DropDownList1").style.display="none";
}
return
}
function getData()
{
var province=document.getElementById("DropDownList1");
var pindex = province.selectedIndex;
var pValue = province.options[pindex].value;
var pText = province.options[pindex].text;
document.getElementById("<%=TextBox1.ClIEntID%>").innerText=pText;
}
</SCRIPT>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<ASP:TextBox ID="TextBox1" runat="server"></ASP:TextBox>
<br>
<ASP:DropDownList ID="DropDownList1" runat="server" Width="192px" style="display:none"></ASP:DropDownList>
</form>
</body>
</Html>