易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net回调更新gridview

      以前写过关于回调的代码,今天想用的时候又找不到了,费了好大劲才搞定,纪录一下,以备后用。
      其实比较简单,关键是最后一行调用的函数renderGrid(_grid)。
      public string sCallBackFunctionInvocation;
string returnstring;
protected void Page_Load(object sender, EventArgs e)
{
sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(this, "message", "processMyResult", "context", "postMyError", true);
}
#region ICallbackEventHandler Members
string ICallbackEventHandler.GetCallbackResult()
{
return returnstring;
}
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
if (eventArgument == "getservertime")
{
//returnstring = DateTime.Now.ToString();
_grid.DataSource = _sampleData;
_grid.DataBind();
renderGrid(_grid);
}
}

      利用ASP.NET中最为强大的特性 - RenderControl。该方法能使我们方便地在服务器端 通过HtmlTextWriter和StirngWriter对象访问到控件的HTML代码。
      private void renderGrid(GridView _grid)
{
using ( StringWriter sw = new StringWriter())
{
HtmlTextWriter htw = new HtmlTextWriter(sw);
_grid.RenderControl(htw);
htw.Flush();
returnstring = sw.ToString();
}
}
      前台响应函数是:
      function processMyResult(returnmessage, context){
window.document.getElementById('Gridview').innerHTML = returnmessage;
}
这样就实现了通过回调函数局部更新gridview。


相关文档:

浅谈ASP.net安全编程

在Web编程过程中,存在着很多安全隐患。比如在以前的ASP版本中,Cookie为访问者和编程者都提供了方便,并没有提供加密的功能。打开IE浏览器,选择“工具”菜单里的“Internet选项”,然后在弹出的对话框里单击“设置”按钮,选择“查看文件”按钮,在弹出的窗口中,就会显示硬盘里 ......

Silverlight应用程序中如何获取ASP.NET页面参数

概述
在开发Silverlight应用程序时,我们经常会遇到这样一种情况,需要在Silverlight应用程序的UserControl中获取ASP.NET页面参数,这个参数不一定来自于当前Silverlight应用程序的宿主页面,而有可能来自于其它的ASP.NET页面。
本文我们简单的介绍一下如何在Silverlight应用程序中获取ASP.NET页面参数。
需求
如下面的 ......

asp.net使用精灵墨林提示找不到指定模块

窗体代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AgentObjects;
using SpeechLib;
using System.Web;
using System.Threading;
using System.Text.RegularExpressio ......

刚刚面试asp.net题

今天去面试刚刚回来,趁着刚才提问的问题还在脑海里,现在赶快写出来分享分享,问的问题比较的多。,单圈是关于ASP.net和它周边的技术问题,我有几个都没回答上来,修炼不够啊
(1)首先是让我介绍一下自己的情况::我就从大一开始说,学到的关于网络、软件这方面的知识,一直说到大四,现在找工作,是不是缺少啥呢??。 ......

asp.net面试答案补充3 .net的垃圾回收机制

.net 垃圾回收机制 【转帖】
2009-02-13 17:44
net内存回收与Dispose﹐Close﹐Finalize方法
一. net的对象使用一般分为三种情况﹕
1.创建对象
2.使用对象
3.释放对象
二.创建对象
1.创建对象实际分为两个步骤﹕变量类型宣告和初始化对象
2.变量类型宣告(declare),如﹕
FileStream ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号