Asp.net combined with Yui 3.0 small example

Source: Internet
Author: User

Note: I only use some things in the I/O space for the background, and paste a small cascade effect,
Get it first Code Talking, Copy code The Code is 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> select </option> ";
Speccode. setcontent ("<option selected = selected> load 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> select </option> ";
Years. setcontent ("<option selected = selected> load 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> load 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 ){
// This can be connected all the time
}
Function successhandler (ID, O, argS ){
If (ARGs! = NULL)
If (ARGs. event! = NULL)
{
If (ARGs. event = 'shengchang ')
{
VaR root = o.responsexml.doc umentelement;
VaR speciality = Y. node. Get ('#' + config. speciality );
VaR content = "<option selected = selected> select </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.doc umentelement;
VaR yearlist = Y. node. Get ('#' + config. years );
VaR content = "<option selected = selected> select </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 = 'earchange ')
{
VaR root = o.responsexml.doc umentelement;
VaR timeslist = Y. node. Get ('#' + config. Times );
VaR content = "<option selected = selected> select </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 obtained successfully ");
}
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 The Code is 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">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>
<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>
</Html> Copy code The Code is 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 ());

}
}

The above is the main code. The above JS actually writes a request for a WebService. You can change it to An ASPX page,

Some data processed by the backend is not pasted out. the backend of every cascade request returns an array of objects. The specific explanation is needless to say, but I am not familiar with it...

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.