asp.net combination Yui 3.0 Small Example _ practical skills

Source: Internet
Author: User
Note: Because I mainly do backstage to use only the IO space below some things, paste a small cascade effect come on,
Cut the crap and talk about the code first.
Copy Code code as follows:

demo.show={
Test:function (E,y)
{
Config=demo.config;
function Onshengchange (e)
{
var sheng = y.node.get (' # ' +config.sheng). Get ("value");
var speccode = y.node.get (' # ' +config.speciality);
var years = Y.node.get (' # ' +config.years);
var timeslist =y.node.get (' # ' +config.times);
var content= "<option selected=selected> please choose </option>";
Speccode.setcontent ("<option selected=selected> loading Data ....</option>");
Years.setcontent (content);
Timeslist.setcontent (content);
var requestspeciality = Y.io ("Test.aspx", {
Method: "POST",
Data: "Type=sheng&sheng=" +sheng,
Arguments:{event: "Cclchange"},
On
{
Success:successhandler,
Failure:failurehandler
}
}
);
}
function Onspecialitychange (e)
{

var sheng = y.node.get (' # ' +config.sheng). Get ("value");
var speccode = y.node.get (' # ' +config.speciality). Get ("value");
var years = Y.node.get (' # ' +config.years);
var timeslist =y.node.get (' # ' +config.times);
var content= "<option selected=selected> please choose </option>";
Years.setcontent ("<option selected=selected> loading Data ....</option>");
Timeslist.setcontent (content);
var requestspeciality = Y.io ("Test.aspx", {
Method: "POST",
Data: "type=speciality&cclid=" +ccl+ "&speccode=" +speccode,
Arguments:{event: "Specchange"},
On
{
Success:successhandler,
Failure:failurehandler
}
}
);
}
function Onyearchange (e)
{
var sheng = y.node.get (' # ' +config.sheng). Get ("value");
var speccode = y.node.get (' # ' +config.speciality). Get ("value");
var year = Y.node.get (' # ' +config.years). Get ("value");
var timeslist =y.node.get (' # ' +config.times);
Timeslist.setcontent ("<option selected=selected> loading Data ....</option>");
var requestspeciality = Y.io ("Test.aspx", {
Method: "POST",
Data: "type=year&sheng=" +sheng+ "&speccode=" +speccode+ "&year=" +year,
Arguments:{event: "Yearchange"},
On
{
Success:successhandler,
Failure:failurehandler
}
}
);
}

function Ontimeslistchagne (e) {
You can keep it going.
}
function Successhandler (ID, O,args) {
if (args!=null)
if (args.event!=null)
{
if (args.event== ' Shengchange ')
{
var root = o.responsexml.documentelement;
var speciality =y.node.get (' # ' +config.speciality);
var content= "<option selected=selected> please choose </option>";
for (i=0;i<root.childnodes.length;i++)
{
var node=root.childnodes[i];
var value=node.getelementsbytagname ("Code") [0].text;
var text=node.getelementsbytagname ("CName") [0].text;
content+= "<option value=" +value + ">" +text+ "</option>";
}
Speciality.setcontent (content);
}
else if (args.event== ' Specchange ')
{
var root = o.responsexml.documentelement;
var yearlist =y.node.get (' # ' +config.years);
var content= "<option selected=selected> please choose </option>";
for (i=0;i<root.childnodes.length;i++)
{
var Value=root.childnodes[i].text;
var Text=value;
content+= "<option value=" +value + ">" +text+ "</option>";
}
Yearlist.setcontent (content);
}
else if (args.event== ' Yearchange ')
{
var root = o.responsexml.documentelement;
var timeslist =y.node.get (' # ' +config.times);
var content= "<option selected=selected> please choose </option>";
var times=y.datatype.number.parse (Root.text);
if (times==null)
times=0;
for (i=0;i<times;i++)
{
content+= "<option value=" + (i+1) + ">" + (i+1) + "</option>";
}
Timeslist.setcontent (content);
}

}
}


function Failurehandler (ID, O) {
Alert ("Data acquisition success");
}
var sheng = y.node.get (' # ' +config.sheng);
var speccode = y.get (' # ' +config.speciality);
var year = Y.get (' # ' +config.years);
var timeslist =y.node.get (' # ' +config.times);

Sheng.on ("Change", Oncclchange);
Speccode.on ("Change", Onspecialitychange);
Year.on ("Change", Onyearchange);
Timeslist.on ("Change", Ontimeslistchagne);

}
};
YUI (). Use ("Node", "Datatype-number", "Io-base", function (Y) {
function onload (e)
{
Demo.show.Test (E,y);
}
Y.on ("Load", onload, window);
});


Copy Code code as follows:

<%@ Page language= "C #" autoeventwireup= "true" codefile= "Test.aspx.cs" inherits= "Test"%>
<! 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>
<form id= "Form1" runat= "Server" >
<div>
<asp:dropdownlist id= "sheng" runat= "Server" >
</asp:DropDownList>
<asp:dropdownlist id= "speciality" runat= "Server" >
</asp:DropDownList>
<asp:dropdownlist id= "Year" runat= "Server" >
</asp:DropDownList>
<asp:dropdownlist id= "Times" runat= "Server" >
</asp:DropDownList>
</div>
</form>
</body>


Copy Code code as follows:

Using System;
Using System.Collections;
Using System.Configuration;
Using System.Data;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.HtmlControls;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
public partial class Test:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
if (! Page.ClientScript.IsClientScriptIncludeRegistered ("YUI"))
Page.ClientScript.RegisterClientScriptInclude ("YUI", Path + "/build/yui/yui-min.js");
if (! Page.ClientScript.IsClientScriptIncludeRegistered ("Clinet"))
Page.ClientScript.RegisterClientScriptInclude ("clinet", Path + "/js/clinet.js");
StringBuilder Scriptblock = new StringBuilder ();
Scriptblock.append ("<script type=" Text/javascript "><!--
");
Scriptblock.append ("demo.config={");
Scriptblock.append ("Sheng:" + This.sheng.ClientID + "',");
Scriptblock.append ("Speciality:" + This.specialityList.ClientID + "',");
Scriptblock.append ("Years:" + This.yearList.ClientID + "',");
Scriptblock.append ("Times:" + This.timesList.ClientID + "");
Scriptblock.append ("};");
Scriptblock.append ("
--></script> ");
Page.ClientScript.RegisterClientScriptBlock (GetType (), "Qualityassessmentplancascadingdropdown", Scriptblock.tostring ());

}
}

This is the main code above, the above paragraph JS I actually wrote the request is a webservice, you can change an ASPX page is OK,

There are some background processing to the data is not posted, each cascade request backstage is to return an object array, the specific explanation is needless to say, do not understand in the discussion ...
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.