Ajax Linkage Drop-down Box Implementation example (. net)

Source: Internet
Author: User

This is the use of Ajax technology, the refresh is positive, is at the speed we do not perceive to complete. XMLHTTP Sacrifice page method, we can not see the refresh, because all the work is in the Sacrifice page, inside the "boil" "toss", we can not see, efficiency on the worse!

AjaxPro.dll Download Address Http://ajaxpro.schwarz-interactive.de/download/ajaxpro.zip

Web.config
<?xml version= "1.0"?>
<configuration>
<system.web>
<add verb= "Post,get" path= "Ajax/*.ashx" type= "Ajax.pagehandlerfactory, Ajax"/>
<add verb= "Post,get" path= "Ajaxpro/*.ashx" type= "ajaxpro.ajaxhandlerfactory,ajaxpro.2"/>
</system.web>
</configuration>

Ajaxtest.aspx

<%@ Page language= "C #" autoeventwireup= "true" codefile= "AjaxTest.aspx.cs" inherits= "Ajaxtest"%>

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<title> Untitled Page </title>


<body>
<script language= "javascript" type= "Text/javascript" >
function Arearesult ()
{
var Area=document.getelementbyid ("DropDownList1");
alert (Area.value);
Ajaxtest.getcitylist (Area.value,get_city_result_callback);
}
function Get_city_result_callback (response)
{
if (Response.value!= null)
{
document.all ("DropDownList2"). 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].name;
var id=ds. Tables[0]. Rows[i].id;
document.all ("DropDownList2"). Options.add (New Option (Name,id));
}
document.all ("TextBox1"). value= "";
}
}
Return
}

</script>
<form id= "Form1" runat= "Server" >
&nbsp;&nbsp;
<asp:dropdownlist id= "DropDownList1" runat= "Server" >
</asp:DropDownList>
<asp:dropdownlist id= "DropDownList2" runat= "Server" >
</asp:DropDownList>&nbsp;
<br/>
</form>
</body>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.