zoukankan
html css js c++ java
asp.net 2.0中用 ICallbackEventHandler 实现无刷新联动
vs2005beta2 中通过
<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
Default2.aspx.cs
"
Inherits
=
"
Default2
"
%>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
runat
="server"
>
<
title
>
Untitled Page
</
title
>
<
script
>
function
ClientCallback(result, context)
{
var
dropdown2
=
document.forms[
0
].elements['DropDownList2'];
dropdown2.innerHTML
=
""
;
var
rows
=
result.split('
|
');
alert(result.length);
for
(
var
i
=
0
; i
<
rows.length
-
1
;
++
i)
{
var
values
=
rows[i]
var
option
=
document.createElement(
"
OPTION
"
);
option.value
=
values;
option.innerHTML
=
values;
dropdown2.appendChild(option);
}
}
function
GetOrders(arg, context)
{
<%=
callBack
%>
;
}
</
script
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server"
>
<
div
>
<
asp:SqlDataSource
ID
="SqlDataSource1"
runat
="server"
ConnectionString
="<%$ ConnectionStrings:pubsConnectionString2 %>"
SelectCommand
="SELECT [au_id], [au_lname], [au_fname] FROM [authors]"
>
</
asp:SqlDataSource
>
<
asp:DropDownList
ID
="DropDownList1"
runat
="server"
>
</
asp:DropDownList
>
<
asp:DropDownList
ID
="DropDownList2"
runat
="server"
>
</
asp:DropDownList
></
div
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
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.Data.SqlClient;
public
partial
class
Default2 : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(
!
this
.IsPostBack)
{
this
.DropDownList1.DataSource
=
this
.SqlDataSource1;
this
.DropDownList1.DataTextField
=
"
au_lname
"
;
this
.DropDownList1.DataValueField
=
"
au_id
"
;
this
.DropDownList1.DataBind();
this
.DropDownList1.Attributes.Add(
"
onchange
"
,
"
GetOrders(this.options[this.selectedIndex].value,'bbbbb');
"
);
}
}
protected
String callBack
{
get
{
return
this
.ClientScript.GetCallbackEventReference(
this
,
"
arg
"
,
"
ClientCallback
"
,
"
context
"
);
}
}
public
string
RaiseCallbackEvent(
string
eventArgument)
{
DataSet ds
=
new
DataSet();
SqlConnection cnn
=
new
SqlConnection (
"
Data Source=JKDL-PORTAL;Initial Catalog=pubs;Persist Security Info=True;User ID=sa;Password=111
"
);
SqlDataAdapter da
=
new
SqlDataAdapter(
"
select titles.title_id,title from titles inner join titleauthor on titleauthor.title_id = titles.title_id where au_id = '
"
+
eventArgument
+
"
'
"
, cnn);
cnn.Open ();
da.Fill(ds);
System.Text.StringBuilder str
=
new
System.Text.StringBuilder();
foreach
(DataRow dr
in
ds.Tables[
0
].Rows)
{
str.Append(dr[
"
title
"
]);
str.Append(
"
|
"
);
}
return
str.ToString ();
}
}
呵..... 越来越好了....
参考
http://www.extremeexperts.com/Net/Articles/ClientCallbacksinASPNETWhidbey.aspx
查看全文
相关阅读:
vue中使用better-scroll实现滑动效果
better-scroll一个好用的页面滑动工具
display:table和display:table-cell结合使用
大小图片
axios的使用
vue中两种路由跳转拼接参数
Android 核心分析 之七Service深入分析
Android 核心分析 之六 IPC框架分析 Binder,Service,Service manager
Android 核心分析 之五基本空间划分
Android核心分析之四手机的软件形态
原文地址:https://www.cnblogs.com/gwazy/p/207480.html
最新文章
Filter plugins ? mutate:
Codec plugins ? multiline
logstash 通过mysql 慢日志了解(?m)
logstash 处理tomcat catalina.out
perl 分析mysql binlog
perl 正则详解
logstash (?m) 经典例子
logstash multiline
8.2.1.15 ORDER BY Optimization ORDER BY 优化
activity 接回返回值
热门文章
一个小的考试系统 android 思路
小米手环与IPAD的连接
很好的资源 for android
golang passing an array to a function
the way to go
golang md5
golang 方法内部定义子方法及调用
go reflect 调用方法
JDOM
阿里图标使用
Copyright © 2011-2022 走看看