ICallbackEventHandler接口实现多级联动
来源:互联网 发布:qq自动留言软件 编辑:程序博客网 时间:2024/06/09 23:05
从一位老兄的Blog上看到了这个,可是代码却不太全(至少我这里看不全)。于是想办法补充了一点:
1、客户端脚本:
function CallServer()
{
var product = "测试";
<%= ClientScript.GetCallbackEventReference(this, "product", "ReceiveServerData",null)%>;
}
function ReceiveServerData(rValue)
{
alert(rValue);
window.location.reload();
var tt=document.getElementById("TextBox1");
alert(tt.DataSource);
}
function selectChange(e)
{
for(var i=0;i<e.options.length;i++)
{
if(e.options[i].selected==true)
{
selectSon(e.options[i].value); break;
}
}
}
function selectSon(e)
{
<%= ClientScript.GetCallbackEventReference(this, "e", "ReceiveServerData",null)%>;
}
function ReceiveServerData(rValue)
{
var son=form1.elements["SelSon"];
var s=rValue.split("|");
son.length=s.length;
for(var i=0;i<s.length-1;i++)
{
son.options[i+1]=new Option(s[i],s[i]);
}
}
/////////////////////
function selectChangeSon(e)
{
for(var i=0;i<e.options.length;i++)
{
if(e.options[i].selected==true)
{
select(e.options[i].value); break;
}
}
}
function select(e)
{
<%= ClientScript.GetCallbackEventReference(this, "e", "hello",null)%>;
}
function hello(rValue)
{
var child=form1.elements["Sel"];
var s=rValue.split("|");
child.length=s.length;
for(var i=0;i<s.length-1;i++)
{
child.options[i+1]=new Option(s[i],s[i]);
}
}
</script>
2、aspx页面代码
<select id="SelParent" runat="server" onchange="selectChange(this)">
<option selected="selected" value="0">请选择 </option>
</select>
<br />
<select id="SelSon" runat="server" onchange="selectChangeSon(this)">
<option selected="selected" value="0">请选择 </option>
</select>
<br />
<select id="Sel">
<option selected="selected" value="0">请选择</option>
</select>
3、服务器端代码
OracleConnection conn = new OracleConnection("Data Source=?;UID=?;PWD=?");
protected void Page_Load(object sender, EventArgs e)
{
ParentBind();
}
private string resualt;
private void ParentBind()
{
string str = "select distinct(CID) from multimenu order by cid";
DataSet ds = ExecuteSql4Ds(str);
SelParent.DataSource = ds;
SelParent.DataTextField = "cid";
SelParent.DataBind();
}
private string SonBind(string e)//绑定第二级
{
string str = "select distinct(CCID) from multimenu where CID=" + e;
DataSet ds = ExecuteSql4Ds(str);
string s = "";
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
s += ds.Tables[0].Rows[i][0] + "|";
return s;
}
private string ChildBind(string e)//绑定第三级
{
string str = "select distinct(CCCID) from multimenu where CCID=" + e;
DataSet ds = ExecuteSql4Ds(str);
string s = "";
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
s += ds.Tables[0].Rows[i][0] + "|";
return s;
}
private DataSet ExecuteSql4Ds(string str)
{
OracleCommand cmd = new OracleCommand(str, conn);
OracleDataAdapter da = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
}
void ICallbackEventHandler.RaiseCallbackEvent(String eventArgument)
{
if (eventArgument.Length == 1)//绑定第二级,我的数据库里分别是用1,11,111来代表三级,所以长度为一的就是一级,大家可以根据自己的需要把修改
{
string eventArgument1 = SonBind(eventArgument);
resualt = eventArgument1;
}
else
{
string eventArgument2 = ChildBind(eventArgument);
resualt = eventArgument2;
}
}
string ICallbackEventHandler.GetCallbackResult()
{
return resualt;
}
4、数据库脚本
create table MULTIMENU
(
ID NUMBER(2) not null,
CID NUMBER(2) not null,
DSCT VARCHAR2(30) not null,
CCID NUMBER(2),
CCCID NUMBER(3)
)
- ICallbackEventHandler接口实现多级联动
- 使用ICallbackEventHandler接口实现的轻量级下拉框联动
- 使用ICallbackEventHandler接口实现的轻量级下拉框联动
- ajax 实现多级联动。
- jQuery 实现多级联动
- EasyUI实现多级联动
- Jquery实现多级联动
- ajax 实现多级联动
- jquery实现多级联动
- ICallbackEventHandler 接口
- 利用ICallbackEventHandler接口实现异步调用
- c#通过ICallbackEventHandler接口实现回调
- 利用ICallbackEventHandler接口实现异步调用
- 使用ICallbackEventHandler接口更高效实现Ajax
- Ajax实现多级联动菜单
- Ajax实现多级联动菜单
- 多级目录联动效果实现
- 多级接口实现方法
- apache https反向代理设置方案
- the beginning of learning struts
- 用于实现Web Services安全性的HTTPS
- 给我一根网线
- 11月21日——培训第二天
- ICallbackEventHandler接口实现多级联动
- struts 用法
- 等待
- linux中string库函数的实现,笔试时常考
- ASCII编码表
- Linux+Apache+PHP+MySQL+SSL配置详解
- [ZT]Member Function Pointers and the Fastest Possible C++ Delegates
- 成为嵌入式程序员应知道的0x10个问题——笔试常考
- ASCII 编码表