asp.Net結合YUI 3.0小例

8738 ワード

注:私が主にバックグラウンドをしているので、IO空間の下にあるものだけを使って、小さなカスケード効果を貼りましょう.
くだらないことは言わないでコードを持って話してください.
 
  
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="";
speccode.setContent("");
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="";
years.setContent("");
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("");
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){
//
}
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="";
             for(i=0;i             {
             var node=root.childNodes[i];
             var value=node.getElementsByTagName("Code")[0].text;
             var text=node.getElementsByTagName("CName")[0].text;
             content+="";
             }
             speciality.setContent(content);
}
else if(args.event=='specchange')
{
var root = o.responseXML.documentElement;
var yearlist =Y.Node.get('#'+config.years);
var content="";
             for(i=0;i             {            
             var value=root.childNodes[i].text;
             var text=value;
             content+="";
             }
             yearlist.setContent(content);
}
else if(args.event=='yearchange')
{
var root = o.responseXML.documentElement;
var timeslist =Y.Node.get('#'+config.times);
var content="";
var times=Y.DataType.Number.parse(root.text);
if(times==null)
times=0;
             for(i=0;i             {            
             content+="";
             }
             timeslist.setContent(content);
}

            }
        }

        
        function failureHandler(id, o){
        alert(" ");
        }
        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);
});
 
  





















 
  
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("<!-- <br>"); <br>scriptBlock.Append("Demo.config={"); <br>scriptBlock.Append("sheng:'" + this.sheng.ClientID + "',"); <br>scriptBlock.Append("speciality:'" + this.specialityList.ClientID + "',"); <br>scriptBlock.Append("years:'" + this.yearList.ClientID + "',"); <br>scriptBlock.Append("times:'" + this.timesList.ClientID + "'"); <br>scriptBlock.Append("};"); <br>scriptBlock.Append(" <br>// -->");
Page.ClientScript.RegisterClientScriptBlock(GetType(), "QualityAssessmentPlanCascadingDropDown", scriptBlock.ToString());

}
}

この上は主なコードで、上のJSは私が実際に書いた要求はWEBServiceで、あなたはaspxページを変えてもいいです.
また、データが貼られていないバックグラウンドもあります.各カスケードリクエストのバックグラウンドはオブジェクト配列を返し、具体的な解釈はもちろん、分からないことが議論されています.の