一套使用简单的Ajax服务器控件-Anthem.NET

经常去codeproject的肯定见过,最近上面发布了 一套非常好用的Ajax服务器控件目前评价已经很高了
 
51 votes for this article.
Popularity: 8.06. Rating: 4.72 out of 5.

一、设计思路简单清晰

我们以往的使用的框架或自己直接使用 xmlhttp直接实现Ajax都难免要写一些javascript脚本,而这个最大的亮点(本来想用卖点的,但是人家是开源项目 OpenSource project)就是使用时不一定要书写js脚本,使用成本极低,昨天仔细观察了一下他的部分源码,觉得作者的思路的确不错,简单明了;严格意义上讲这不是套框架,而是封装良好的控件,而且感觉比微软将要推出的atlas控件简单,或许使用前几天发布源代码的AjaxPro可以编写出这么一套控件也没什么难的;
 
二、使用简单

以他上面最简单的demo:Introduction using buttons and labels  为例
他的步骤是:
Steps
1.Add a Register directive to the top of your page: 

<% @ Register TagPrefix = " anthem "  Namespace = " Anthem "  Assembly = " Anthem "   %>
2.Add an anthem:Button control to your page: 

< anthem:Button id = " button "  runat = " server "  Text = " Click Me! "   />
3.Add an anthem:Label control to your page: 

< anthem:Label id = " label "  runat = " server "   />
4.Add a handler 
for  the button's Click event either by  double - clicking on the button  in  the designer or by adding an OnClick attribute to the button's tag: 

< anthem:Button id = " button "  runat = " server "  Text = " Click Me! "  OnClick = " button_Click "   />
5.Implement the handler 
in  your code behind class or  in  a server - side script block  in  your page. Set the Text property like a normal Label control but make sure you set the UpdateAfterCallBack property to  true  or you won't see the change reflected on the page: 

< script runat = " server " >

void  button_Click(object sender, EventArgs e)
{
 label.Text 
= DateTime.Now.ToString();
 label.UpdateAfterCallBack 
= true;
}


</ script >

后来我觉得前1234步其实不需要,在其源码的每个控件命名空间上加上
[assembly: TagPrefix( " Anthem " " Anthem " )]

也就省了,但是作者为什么不加,不得其解,至于5步的button_Click脚本,可以写到cs脚本中,岂不是与一般控件一样?

三、支持vs2003和vs2005两种版本
代码中有了很多宏,同时支持两个版本!

有兴趣去下来看看,相信能受益……

 

 

http://hedonister.cnblogs.com/archive/2006/02/22/335272.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值