web自定义控件是否能有自己的AJAX---asp.net2.0
解决方案 »
- repeater 更新数据(急问!)
- 多文件上传并排序
- 一个问题从去年留今年,再次提问!!!盼请CSDN高手!!!
- 关于RridView控件的高级应用
- 如果在DataList模板中不放入表格,怎么实现数据之间的分隔线 ??
- asp.net 1.1中在代码隐藏模块中,怎么使用Request,Response,Server,Session,Application对象?
- asp.net 2005 打开网页问题
- 为何datagrid中column.count的值不是0就是1,现在我想在第n列动态增加一列,但老是出错
- 我的ASP.NET WEB启动不了,说aspnet_wp有错误
- ASP.NET网站中使用正则验证控件的问题
- Repeater 中放 LinkButton
- [原创]大型web2.0社区系统(含BBS,博客,新闻,图库,sns)jlcms2.0(金龙2)准备发布中
testAjax.ascx<%@ Control Language="C#" AutoEventWireup="true" CodeFile="testAjax.ascx.cs" Inherits="testAjax" %>
<script type="text/javascript">
function LookUpStock()
{
var product = 'ppp';
CallServer(product, "");
}
function ReceiveServerData(rValue)
{
Results.innerText = rValue;
}
</script>
<table>
<tr>
<td>
<button onclick="LookUpStock()">Look Up Stock</button>
<br />
<br />
Items in stock: <span ID="Results"></span>
<br />
</td>
</tr>
</table>testAjax.ascx.csusing 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;public partial class testAjax : System.Web.UI.UserControl, ICallbackEventHandler
{
private string str; protected void Page_Load(object sender, EventArgs e)
{
String cbReference =
this.Page.ClientScript.GetCallbackEventReference(this,
"arg", "ReceiveServerData", "context");
String callbackScript;
callbackScript = "function CallServer(arg, context)" +
"{ " + cbReference + "} ;";
this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"CallServer", callbackScript, true);
} protected void Button2_Click(object sender, EventArgs e)
{ } string ICallbackEventHandler.GetCallbackResult()
{
return str + "xxx";
} void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
str = eventArgument;
}
}