惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
C
Cybersecurity and Infrastructure Security Agency CISA
N
News and Events Feed by Topic
C
Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
Scott Helme
Scott Helme
P
Palo Alto Networks Blog
S
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tor Project blog
量子位
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog RSS Feed
NISL@THU
NISL@THU
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
AWS News Blog
AWS News Blog
爱范儿
爱范儿
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
L
LINUX DO - 最新话题
Security Archives - TechRepublic
Security Archives - TechRepublic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
Cloudbric
Cloudbric
aimingoo的专栏
aimingoo的专栏
L
Lohrmann on Cybersecurity
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hacker News: Ask HN
Hacker News: Ask HN
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
S
Security @ Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
G
GRAHAM CLULEY
P
Proofpoint News Feed
V
V2EX
Martin Fowler
Martin Fowler
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Cloudflare Blog
SecWiki News
SecWiki News
罗磊的独立博客
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
The Last Watchdog
The Last Watchdog

博客园 - 萍踪侠影

c#过滤HTML代码 - 萍踪侠影 - 博客园 也來開發一款日歷控件 制作activeX控件 在aspx頁中獲取DataGrid行序號 - 萍踪侠影 - 博客园 在MasterPage中檢驗User是否登入 - 萍踪侠影 - 博客园 [轉載]Run As Administrator 以編程方式為GridView添加欄位 - 萍踪侠影 - 博客园 Internet Explorer 7中的层叠样式表兼容性 Microsoft Office Web 组件 PivotTable 基础 ASP讀取excel文件 - 萍踪侠影 - 博客园 一個Ajax.NET的查詢實例 js校验的通用工具 將字串轉換為日期型數據的例子 - 萍踪侠影 - 博客园 將datagrid控件內容輸出到excel文件 - 萍踪侠影 - 博客园 C#常用函数集 IPv6 简介 Visual C# 3.0 新特性概览 遍历XML引擎版本以适应代码 微调您的 Web 站点以适应 Windows XP Service Pack 2
初探AJAX.NET
萍踪侠影 · 2006-01-17 · via 博客园 - 萍踪侠影

 当看到AJAX势头红火时,这个集JavaScript、XML和ASP.NET三种主流WEB技术三合一框架应用的新技术着实让人惊羡不已。以前要实现同样页面无刷新而达到数据互动也有很多方法,但都过于繁琐,且开发人员必须熟练掌握N种不同的语言或技术。例如我可以用iframe+JavaScript实现假无刷新,虽然表面看起来是没有刷新页面,但有音响的时候总能听到“达”的一声:) 现在看看AJAX来实现真正的无刷新吧。
 我们先要下载Ajax.NET类库文件Ajax.dll并将其放入解决方案根目录下的References目录下。

 以下是index.aspx.cs中的部分源码:

 public class index : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.Label Label1;
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   Ajax.Utility.RegisterTypeForAjax(typeof(index));
   if (!Page.IsPostBack)
   {
    this.Label1.Text="Server Control";
   }
 
  }

  [Ajax.AjaxMethod()]
  public string ShowText()
  {
   return "this is a ajax page.";
  }
 }

 接着要在index.aspx文件中写一些javascript代码,并将按钮的Click事件指定为ShowText():

 <script language="javascript">
 function ShowText()
 {
  //与Server端同名方法的客户端函数;
  //执行服务器端方法;
  index.ShowText(ShowText_CallBack);
 }
 
 function ShowText_CallBack(response)
 {
  //服务端的回调函数;
  //在此可以设置客户端的显示方式、UI、Data等;
  var msg=document.getElementById("msg");
  msg.innerHTML=response.value;
 }
 </script>