经常去codeproject的肯定见过,最近上面发布了
一套非常好用的Ajax服务器控件目前评价已经很高了
一、设计思路简单清晰
我们以往的使用的框架或自己直接使用 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
"
)]
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 为例
他的步骤是:





























也就省了,但是作者为什么不加,不得其解,至于5步的button_Click脚本,可以写到cs脚本中,岂不是与一般控件一样?
三、支持vs2003和vs2005两种版本
代码中有了很多宏,同时支持两个版本!
有兴趣去下来看看,相信能受益……
http://hedonister.cnblogs.com/archive/2006/02/22/335272.html