一套使用簡單的Ajax伺服器控制項-Anthem.NET

來源:互聯網
上載者:User
經常去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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.