zoukankan
html css js c++ java
ICallbackEventHandler接口实现无刷新调用后台
前台HTML代码
<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
Default.aspx.cs
"
Inherits
=
"
_Default
"
%>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
>
Untitled Page
</
title
>
<
script
type
="text/javascript"
>
<!--
function
test()
{
var
lb
=
document.getElementById(
"
Select1
"
);
//
取的那个下拉框
var
argTxt
=
lb.options[lb.selectedIndex].text;
//
得到你选择的下拉框的文本再调用CallTheServer,由服务器端输出的js函数
CallTheServer(argTxt,'');
}
function
ReceiveServerData(rValue,context)
{
document.getElementById('Results').innerHTML=rValue
;
}
//
-->
</
script
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server"
>
<
div
>
<
select
id
="Select1"
>
<
option
value
="1"
selected
="selected"
>
我为歌狂
</
option
>
<
option
value
="2"
>
正义之名
</
option
>
<
option
value
="3"
>
永不加赋
</
option
>
</
select
>
<
br
/>
<
br
/>
<
input
onclick
="test()"
value
="从服务器返回下拉框文本"
type
="button"
/>
<
br
/>
<
br
/>
<
span
id
="Results"
></
span
>
<
br
/>
</
div
>
</
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;
public
partial
class
_Default : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
//
实现ICallbackEventHandler接口
{
private
string
_callbackEventArgument;
protected
void
Page_Load(
object
sender, EventArgs e)
{
String cbReference
=
Page.ClientScript.GetCallbackEventReference(
this
,
"
arg
"
,
"
ReceiveServerData
"
,
"
context
"
);
String callbackScript;
callbackScript
=
"
function CallTheServer(arg,context)
"
+
"
{
"
+
cbReference
+
"
} ;
"
;
Page.ClientScript.RegisterStartupScript(
this
.GetType(), Guid.NewGuid().ToString(), callbackScript,
true
);
}
public
String RaiseCallbackEvent(String eventArgument)
{
return
"
你选择的是:
"
+
eventArgument;
}
//
自动生成接口成员
ICallbackEventHandler 成员
#region
ICallbackEventHandler 成员
string
ICallbackEventHandler.GetCallbackResult()
{
//
throw new Exception("The method or operation is not implemented.");
return
_callbackEventArgument;
}
void
ICallbackEventHandler.RaiseCallbackEvent(
string
eventArgument)
{
//
throw new Exception("The method or operation is not implemented.");
_callbackEventArgument
=
this
.RaiseCallbackEvent(eventArgument);
}
#endregion
}
查看全文
相关阅读:
装备购买 线性基+贪心
花园 状压DP+矩阵快速幂
数学作业 递推+矩阵快速幂
石头游戏 构造+矩阵快速幂
sumdiv 算术基本定理的推论
huffman
Integer 类型比较大小
java 中的 String 相加
Java 中的 static 关键字
JAVA 基础
原文地址:https://www.cnblogs.com/ding0910/p/430428.html
最新文章
类的内置方法
绑定方法、非绑定方法与反射、内置方法
多态性与鸭子类型
组合与封装
继承与派生
面向对象编程
常用内置模块与包
面试题总结
on_delete的相关使用说明
Django内置用户类AbstractUser与内置认证校验系统
热门文章
重点:models.py文件中的字段和类型解析
Django中blank=True和null=True的区别
印象最深的问题Your STATICFILES_DIRS setting is not a tuple or list; " ImproperlyConfigured: Your STATICFILES_DIRS setting is not a tuple or list; perhaps you forgot a trailing comma?
解决 Nginx: [error] open() "/usr/local/Nginx/logs/Nginx.pid" failed(2:No such file or directory)
warning: LF will be replaced by CRLF in ...... The file will have its original line endings in your working directory. 报错导致的git add . 不成功
报错RuntimeError: Model class apps.user.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
Django报错django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
BSGS&&ExBSGS
CRT&&ExCRT
HDOJ3949 XOR 线性基
Copyright © 2011-2022 走看看