惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
有赞技术团队
有赞技术团队
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements
雷峰网
雷峰网
T
Tor Project blog
博客园_首页
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Register - Security
The Register - Security
T
The Blog of Author Tim Ferriss
Recorded Future
Recorded Future
V
Vulnerabilities – Threatpost
Project Zero
Project Zero
J
Java Code Geeks
AWS News Blog
AWS News Blog
Security Latest
Security Latest
Spread Privacy
Spread Privacy
T
Threatpost
博客园 - 三生石上(FineUI控件)
I
Intezer
G
Google Developers Blog
Scott Helme
Scott Helme
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Hacker News
The Hacker News
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
NISL@THU
NISL@THU
A
Arctic Wolf
F
Full Disclosure
P
Proofpoint News Feed
G
GRAHAM CLULEY
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
N
Netflix TechBlog - Medium
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threat Research - Cisco Blogs
B
Blog
IT之家
IT之家
MongoDB | Blog
MongoDB | Blog
L
LangChain Blog
Know Your Adversary
Know Your Adversary

博客园 - 泽来

java多线程---线程之间的通信 设计原则 适配器模式 java复习进程 java小点滴 转>java5.0新特性 面试题收集 我买的书 java编程思想中关于多态性的描述 javascipt正则表达式 - 泽来 - 博客园 javascript小代码 - 泽来 - 博客园 DataGrid数据在Execel中打开 - 泽来 - 博客园 javascript高级教程 智力题收集 asp.net的TextBox回车触发事件 - 泽来 - 博客园 Builder生成器模式 单件模式(singleton) 是男人就坚持100下(强力益智,请留下战绩) XMLHTTP简介 - 泽来 - 博客园
多级无刷新联动(GB2312编码转换为UTF-8未取得满意效果) - 泽来 - 博客园
泽来 · 2005-11-29 · via 博客园 - 泽来

//此方法根据济览器类型取得对应的传值方法
function getType()
            {
                var A 
= null;
                
try
                {
                    A 
= new ActiveXObject("Msxml2.XMLHTTP");
                }
                
catch(e)
                {
                    
try
                    {
                        A 
= new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    
catch(oc)
                    {
                        A 
= null;
                    }
                }
                
if(!&& typeof XMLHttpRequest != "undefined")
                {
                    A 
= new XMLHttpRequest();
                }
                
return A;
            }
            function Go(obj)
            {
                
//得到第一个下拉列表的值,用于取第三个DropDownList的值时作条件
                var firstValue = document.getElementById("DropName").value;
                
//得到第二个下拉列表的值,用于绑定TextId时作为参考
                var secondValue = "no";
                
if(document.getElementById("DropType").options.length == 0)
                {
                    secondValue 
= "no";
                }
                
else
                {
                    secondValue 
= document.getElementById("DropType").value;
                }
                
//得到当前的下拉列表的值
                var currentControlValue = obj.value;
                
//取得当前下拉列表的名称,用来进行不同的绑定
                var currentControlName = obj.name;
                
//传递控件名称和值给处理页面
                var weburl="HalfFinishedProduct_DropProcess.aspx?CCV='"+currentControlValue+"'&CCN='"+currentControlName+"'&FV='"+firstValue+"'&SV='"+secondValue+"'";
                
//初始化xmlhttp对象
                var xmlhttp = getType();
                
//提交数据
                xmlhttp.open("get",weburl,true);
                
//如果成功返回数据
                xmlhttp.onreadystatechange = function()    
                {
                    
if(xmlhttp.readyState == 4)
                    {
                        
//得到服务器返回的数据
                        var result = xmlhttp.responseText;
                        
if(currentControlName == "DropName")
                        {
                            
                            
//清空要绑定的DropDownList所有下拉项
                            document.getElementById("DropType").length = 0;
                            document.getElementById(
"DropColor").length = 0;
                        
                            document.getElementById(
"DropType").options.add(new Option("所有型号","0"));
                            document.getElementById(
"DropColor").options.add(new Option("所有颜色","0"));
                        
                            
//判断返回的数据是否为空
                            if(result != "")
                            {
                                
//把接收到的数据按 ,  分割成数组
                                var allArray = result.split(",");
                                
//循环这个数组
                                for(var i = 1; i<allArray.length; i++)
                                {
                                    var thisArray 
= allArray[i].split("|");
                                    
//为另外两个下拉列表添加条目
                                    document.getElementById("DropType").options.add(new Option(thisArray[0].toString(),thisArray[0].toString()));
                                    document.getElementById(
"DropColor").options.add(new Option(thisArray[1].toString(),thisArray[1].toString()));
                                }
                            }
                        }
                        
else if(currentControlName == "DropType")
                        {
                            document.getElementById(
"DropColor").length = 0;
                            document.getElementById(
"DropColor").options.add(new Option("所有颜色","0"));
                            
//判断返回的数据是否为空
                            if(result != "")
                            {
                                
//把接收到的数据按 ,  分割成数组
                                var allArray = result.split(",");
                                
for(var i = 1; i<allArray.length; i++)
                                {
                                    var thisArray 
= allArray[i].split("|");
                                    
//绑定颜色控件的值
                                    document.getElementById("DropColor").options.add(new Option(thisArray[1].toString(),thisArray[1].toString()));
                                }                
                                
                            }
                            
                        }
                        
else if(currentControlName == "DropColor")
                        {
                            
if(result != "")
                            {
                                    
//绑定颜色控件的值
                                    document.getElementById("TextID").value = result;
                            }
                            
                        }
                    }
                }
                xmlhttp.send(
null);
            }

//根据页面传过来的信息取得对应的数据然后作用字符串传递给请求页面
//取得控件的名称
        public string droName
        {
            
getreturn (string)ViewState["DropName"];}
            
set{ViewState["DropName"= value;}
        }
        
//取得DropName的值
        public string strDName
        {
            
get{return (string)ViewState["StrName"];}
            
set{ViewState["StrName"= value;}
        }
        
//取得DropType的值
        public string strTName
        {
            
get{return (string)ViewState["StrTName"];}
            
set{ViewState["StrTName"= value;}
        }
private void Page_Load(object sender, System.EventArgs e)
        {
            
// 在此处放置用户代码以初始化页面

            droName 
= "";
            
if(Request.QueryString["FV"!=null)
            {
                strDName 
= Request.QueryString["FV"].Replace("'","");
            }
            
if(Request.QueryString["SV"!=null)
            {
                strTName 
= Request.QueryString["SV"].Replace("'","");
            }
            BindDrop();
        }
        
private void BindDrop()
        {
            
string strName = "";//获取传过来的当前下拉列表的选择值
            if(Request.QueryString["CCV"!= null)
            {
                strName 
= Request.QueryString["CCV"].Replace("'","");
            }
            
if(Request.QueryString["CCN"!= null)
            {
                
//获取传过来的DropDownList的名称来作相应的绑定
                droName = Request.QueryString["CCN"].Replace("'","");
            }
            
//判断是否传值 过来
            if(strName+"aa" != "aa" && droName == "DropName")
            {
                
//触发DropName事件
                BindTypeColor(strName);
            }
            
else if(strName+"aa" != "aa" && droName == "DropType")
            {
                
//触发DropType事件
                BindColor(strDName,strName);
            }
            
else if(strName+"aa" != "aa" && droName == "DropColor")
            {
                
//触发DropColor事件
                BindTextId(strDName,strTName,strName);
            }
        }
        
/// <summary>
        
/// 第一次选择,绑定颜色和类型
        
/// </summary>
        
/// <param name="strName"></param>
        public void BindTypeColor(string strName)
        {
            
string result = "";
            Response.Clear();
            
string selectTc = "select type, Color from HalfFinishedProductDetails where ProductName = @name";
            SqlCommand comm 
= new SqlCommand(selectTc,conn);
            conn.Open();
            comm.Parameters.Add(
new SqlParameter("@name",SqlDbType.VarChar,20));
            comm.Parameters[
"@name"].Value = strName;
            SqlDataReader sdr 
= comm.ExecuteReader();
            
while(sdr.Read())
            {
                result 
+= ","+sdr.GetString(0)+"|"+sdr.GetString(1);
            }
            sdr.Close();
            conn.Close();
            Response.Write(result);
            Response.Flush();
            Response.Close();
        }
        
/// <summary>
        
/// 第二次选择,根据绑定颜色
        
/// </summary>
        
/// <param name="strDName"></param>
        
/// <param name="strType"></param>
        public void BindColor(string strDName, string strType)
        {
            
string result = "";
            Response.Clear();
            
string selectTc = "select HalfFinishedProductID,Color from HalfFinishedProductDetails where ProductName = @name and Type = @type";
            SqlCommand comm 
= new SqlCommand(selectTc,conn);

            comm.Parameters.Add(

new SqlParameter("@name",SqlDbType.VarChar,20));
            comm.Parameters[
"@name"].Value = strDName;

            comm.Parameters.Add(

new SqlParameter("@type",SqlDbType.VarChar,20));
            comm.Parameters[
"@type"].Value = strType;

            conn.Open();
            SqlDataReader sdr 

= comm.ExecuteReader();
            
while(sdr.Read())
            {
                
try
                {
                    result 
+= ","+sdr.GetInt32(0).ToString()+"|"+sdr.GetString(1);
                }
                
catch(Exception eee )
                {
                    Response.Write(eee.Message);
                }
                
            }
            sdr.Close();
            conn.Close();
            Response.Write(result);
            Response.Flush();
            Response.Close();
        }
        
/// <summary>
        
/// 第三次选择,跟根前面的名称,类型,颜色三个条件确定TextTd的值
        
/// </summary>
        public void BindTextId(string name, string type, string color)
        {
            
string result = "";
            Response.Clear();
            
string selectId = "select HalfFinishedProductID from HalfFinishedProductDetails where ProductName = @name and Type = @type and color=@color";
            SqlCommand comm 
= new SqlCommand(selectId, conn);
            
            comm.Parameters.Add(
new SqlParameter("@name",SqlDbType.VarChar,20));
            comm.Parameters[
"@name"].Value = name;

            comm.Parameters.Add(

new SqlParameter("@type",SqlDbType.VarChar,20));
            comm.Parameters[
"@type"].Value = type;

            comm.Parameters.Add(

new SqlParameter("@color",SqlDbType.VarChar,20));
            comm.Parameters[
"@color"].Value = color;

            conn.Open();
            SqlDataReader sdr 

= comm.ExecuteReader();
            
while(sdr.Read())
            {
                result 
= sdr.GetInt32(0).ToString();
            }

            sdr.Close();
            conn.Close();
            Response.Write(result);
            Response.Flush();
            Response.Close();
        }

如果WebConfig里
<globalization requestEncoding="UTF-8" responseEncoding="UTF-8"/>
设置为UTF
-8则xmlHttp不能传输中文,应改为GB2312


//vbscript将gb2312转为uft-8的代码,用javascript调用时不成功。
<script language="vbscript" >
            Function DeCodeAnsi(s)
            Dim i, sTmp, sResult, sTmp1
            sResult 
= ""
            For i
=1 To Len(s)
            If Mid(s,i,
1)="%" Then
            sTmp 
= "&H" & Mid(s,i+1,2)
            If isNumeric(sTmp) Then
            If CInt(sTmp)
=0 Then
            i 
= i + 2
            ElseIf CInt(sTmp)
>0 And CInt(sTmp)<128 Then
            sResult 
= sResult & Chr(sTmp)
            i 
= i + 2
            Else
            If Mid(s,i
+3,1)="%" Then
            sTmp1 
= "&H" & Mid(s,i+4,2)
            If isNumeric(sTmp1) Then
            sResult 
= sResult & Chr(CInt(sTmp)*16*16 + CInt(sTmp1))
            i 
= i + 5
            End If
            Else
            sResult 
= sResult & Chr(sTmp)
            i 
= i + 2
            End If
            End If
            Else
            sResult 
= sResult & Mid(s,i,1)
            End If
            Else
            sResult 
= sResult & Mid(s,i,1)
            End If
            Next
            DeCodeAnsi 
= sResult
            End Function
        
</script>
如果将它放在
<script language="javascript">
</script>
之前,javascript里的 value属性会报错,放在这个之后又达不到转换的效果。

暂时还不知如何在
<globalization requestEncoding="UTF-8" responseEncoding="UTF-8"/>这种设置的情况下用javascript转换编码格式。