ClientScript.GetCallbackEventReference几个参数的使用实例
2011-04-25 16:22
399 查看
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="Cl_WebComTest.WebForm3" %>
<!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 runat="server">
<title></title>
<script type="text/javascript">
function fun_callbk(msg,context) {
<%=this.ClientScript.GetCallbackEventReference(this,"msg","showMsg","context")%>
}
function showMsg(rValue,context) {
alert(rValue);
alert(context.UnitText);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div style="cursor:hand;background-color:#ededed;" onclick="var context=new Object;context.UnitText = '个';fun_callbk('大家好',context)">click me</div>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Cl_WebComTest
{
public partial class WebForm3 : System.Web.UI.Page, ICallbackEventHandler
{
string myStr = string.Empty;
public void RaiseCallbackEvent(string arg)
{
myStr = arg + "hello";//还是简单的写,将客户端传来的值赋给咱新声明的变量
//加一个hello,是为了验证数据的确是有服务端处理后返回的
}
public string GetCallbackResult()
{
return myStr;//将结果返回客户端
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
<!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 runat="server">
<title></title>
<script type="text/javascript">
function fun_callbk(msg,context) {
<%=this.ClientScript.GetCallbackEventReference(this,"msg","showMsg","context")%>
}
function showMsg(rValue,context) {
alert(rValue);
alert(context.UnitText);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div style="cursor:hand;background-color:#ededed;" onclick="var context=new Object;context.UnitText = '个';fun_callbk('大家好',context)">click me</div>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Cl_WebComTest
{
public partial class WebForm3 : System.Web.UI.Page, ICallbackEventHandler
{
string myStr = string.Empty;
public void RaiseCallbackEvent(string arg)
{
myStr = arg + "hello";//还是简单的写,将客户端传来的值赋给咱新声明的变量
//加一个hello,是为了验证数据的确是有服务端处理后返回的
}
public string GetCallbackResult()
{
return myStr;//将结果返回客户端
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
相关文章推荐
- js 调用后台方法 ICallbackEventHandler 接口实现局部刷新实例 ClientScript的GetCallbackEventReference方法实现局部刷新
- 非Ajax无刷之ClientScript.GetCallbackEventReference
- ClientScript.GetCallbackEventReference 调用服务端函数
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEvent
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
- HttpClient使用Post和Get提交参数
- ClientScriptManager.GetCallbackEventReference 方法
- .net GetCallbackEventReference参数说明和详细使用
- ClientScript.GetCallbackEventReference实现局部刷新
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEvent
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterF
- HttpClient使用Post和Get提交参数
- GetClinetRect GetWindowRect ScreenToClient ClientToScreen GetCursorPos几个函数的正确使用
- HttpClient 4.1.3 初学篇---使用Get和Post模拟登录简单页面(分别带参数)
- 【转】HttpClient使用Post和Get提交参数
- HttpClient Post和Get请求实例+ 中文参数处理
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterF
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEvent