在调试工具栏,或监视窗口的右键菜单里或工具栏上有一个”按十六进制显示”(Hexadecimal Display),去掉选中就可以.
无刷新DropdownList联动(二级联动)
Eg2
<!
DOCTYPE html PUBLIC
"
-//W3C//DTD XHTML 1.0 Transitional//EN
"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
"
>
<% @ Page Language = " C# " AutoEventWireup = " true " CodeFile = " Default.aspx.cs " Inherits = " _Default " %>
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head runat = " server " >
< title > .net2.0回调实现二级无刷新联动 </ title >
< script type = " text/javascript " >
<!--
function test(arg)
{
if (arg != " button " )
{
var thisArray = arg.split( ' , ' );
document.getElementById( " DropDownList2 " ).length = 0 ;
for (var i = 0 ; i < thisArray.length ;i ++ )
{
document.getElementById( " DropDownList2 " ).options.add( new Option(thisArray[i].toString(),thisArray[i].toString()));
}
}
else
{
document.getElementById( " text " ).innerHTML = " 你选择的大类是: " + document.getElementById( " DropDownList1 " ).value + " 小类是: " + document.getElementById( " DropDownList2 " ).value;
}
}
// -->
</ script >
< style >
</ style >
</ head >
< body >
< form id = " form1 " runat = " server " >
< asp:DropDownList ID = " DropDownList1 " runat = " server " >
< asp:ListItem Text = ' 请选择 ' ></ asp:ListItem >
< asp:ListItem Value = 1 Text = 1 ></ asp:ListItem >
< asp:ListItem Value = 2 Text = 2 ></ asp:ListItem >
</ asp:DropDownList >
< asp:DropDownList ID = " DropDownList2 " runat = " server " >
< asp:ListItem Text = ' 请选择 ' ></ asp:ListItem >
</ asp:DropDownList >
< input type = button onclick = " callserver('3') " value = " 提交 " />
< span id = " text " ></ span >
</ form >
</ body >
</ html >
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page,System.Web.UI.ICallbackEventHandler
{
protected void Page_Load( object sender, EventArgs e)
{
string str = Page.ClientScript.GetCallbackEventReference( this , " arg " , " test " , null , false ); /// 获取一个对客户端函数的引用
string script = " function callserver(arg){ " + str + " } " ; /// 组织一个callserver函数
Page.ClientScript.RegisterClientScriptBlock( this .GetType(), " key " , script, true ); /// 注册客户端脚本
DropDownList1.Attributes.Add( " onchange " , " callserver(document.getElementById('DropDownList1').value) " ); /// 为DropDownList1添加客户端的onchange事件,触发callserver函数
}
#region ICallbackEventHandler 成员
string selecttext = null ;
public string GetCallbackResult()
{
StringBuilder sb = new StringBuilder();
if (selecttext == " 1 " )
{
sb.Append( " 1-1,1-2,1-3 " );
}
else if (selecttext == " 2 " )
{
sb.Append( " 2-1,2-2,2-3 " );
}
else
{
sb.Append( " button " );
}
return sb.ToString(); /// 给客户端函数test返回一个参数sb
}
public void RaiseCallbackEvent( string eventArgument)
{
selecttext = eventArgument; /// 获得客户端提交的参数赋给变量selecttext
}
#endregion
}
<% @ Page Language = " C# " AutoEventWireup = " true " CodeFile = " Default.aspx.cs " Inherits = " _Default " %>
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head runat = " server " >
< title > .net2.0回调实现二级无刷新联动 </ title >
< script type = " text/javascript " >
<!--
function test(arg)
{
if (arg != " button " )
{
var thisArray = arg.split( ' , ' );
document.getElementById( " DropDownList2 " ).length = 0 ;
for (var i = 0 ; i < thisArray.length ;i ++ )
{
document.getElementById( " DropDownList2 " ).options.add( new Option(thisArray[i].toString(),thisArray[i].toString()));
}
}
else
{
document.getElementById( " text " ).innerHTML = " 你选择的大类是: " + document.getElementById( " DropDownList1 " ).value + " 小类是: " + document.getElementById( " DropDownList2 " ).value;
}
}
// -->
</ script >
< style >
</ style >
</ head >
< body >
< form id = " form1 " runat = " server " >
< asp:DropDownList ID = " DropDownList1 " runat = " server " >
< asp:ListItem Text = ' 请选择 ' ></ asp:ListItem >
< asp:ListItem Value = 1 Text = 1 ></ asp:ListItem >
< asp:ListItem Value = 2 Text = 2 ></ asp:ListItem >
</ asp:DropDownList >
< asp:DropDownList ID = " DropDownList2 " runat = " server " >
< asp:ListItem Text = ' 请选择 ' ></ asp:ListItem >
</ asp:DropDownList >
< input type = button onclick = " callserver('3') " value = " 提交 " />
< span id = " text " ></ span >
</ form >
</ body >
</ html >
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page,System.Web.UI.ICallbackEventHandler
{
protected void Page_Load( object sender, EventArgs e)
{
string str = Page.ClientScript.GetCallbackEventReference( this , " arg " , " test " , null , false ); /// 获取一个对客户端函数的引用
string script = " function callserver(arg){ " + str + " } " ; /// 组织一个callserver函数
Page.ClientScript.RegisterClientScriptBlock( this .GetType(), " key " , script, true ); /// 注册客户端脚本
DropDownList1.Attributes.Add( " onchange " , " callserver(document.getElementById('DropDownList1').value) " ); /// 为DropDownList1添加客户端的onchange事件,触发callserver函数
}
#region ICallbackEventHandler 成员
string selecttext = null ;
public string GetCallbackResult()
{
StringBuilder sb = new StringBuilder();
if (selecttext == " 1 " )
{
sb.Append( " 1-1,1-2,1-3 " );
}
else if (selecttext == " 2 " )
{
sb.Append( " 2-1,2-2,2-3 " );
}
else
{
sb.Append( " button " );
}
return sb.ToString(); /// 给客户端函数test返回一个参数sb
}
public void RaiseCallbackEvent( string eventArgument)
{
selecttext = eventArgument; /// 获得客户端提交的参数赋给变量selecttext
}
#endregion
}
http://blog.163.com/tianshenglongchang@126/blog/static/16462850320106311111217/
显示中文: http://www.west263.com/www/info/33996-1.htm
http://www.sudu.cn/info/html/edu/20071109/98473.html
http://www.360doc.com/content/09/0518/11/109051_3549391.shtml