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

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

一、设计思路简单清晰

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

以他上面最简单的demo:Introduction using buttons and labels  为例
他的步骤是:
None.gif Steps
None.gif1.Add a Register directive to the top of your page: 
None.gif
None.gif
<% @ Register TagPrefix = " anthem "  Namespace = " Anthem "  Assembly = " Anthem "   %>
None.gif2.Add an anthem:Button control to your page: 
None.gif
None.gif
< anthem:Button id = " button "  runat = " server "  Text = " Click Me! "   />
None.gif3.Add an anthem:Label control to your page: 
None.gif
None.gif
< anthem:Label id = " label "  runat = " server "   />
None.gif4.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: 
None.gif
None.gif
< anthem:Button id = " button "  runat = " server "  Text = " Click Me! "  OnClick = " button_Click "   />
None.gif5.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: 
None.gif
None.gif
< script runat = " server " >
None.gif
None.gif
void  button_Click(object sender, EventArgs e)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif label.Text 
= DateTime.Now.ToString();
InBlock.gif label.UpdateAfterCallBack 
= true;
ExpandedBlockEnd.gif}

None.gif
None.gif
</ script >
None.gif
None.gif
后来我觉得前1234步其实不需要,在其源码的每个控件命名空间上加上
None.gif [assembly: TagPrefix( " Anthem " " Anthem " )]
也就省了,但是作者为什么不加,不得其解,至于5步的button_Click脚本,可以写到cs脚本中,岂不是与一般控件一样?

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

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

ps: 新建一个技术群19798587,主要交流Ajax&Altas技术

转载于:https://www.cnblogs.com/Hedonister/archive/2006/02/22/335272.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值