026-微软Ajax异步组件
ASP.Net中內(nèi)置的簡(jiǎn)化AJAX開(kāi)發(fā)的控件UpdatePanel
放入ScriptManager,將要實(shí)現(xiàn)AJAX效果的控件放到UpdatePanel中即可。
UpdatePanel原理探秘,用HttpWatch看。
只把需要無(wú)刷新更新的部分放到UpdatePanel中。
UpdatePanel用來(lái)實(shí)現(xiàn)一些對(duì)性能要求不高的需求非常方便。
從原理分析為什么在客戶端把TextBox變紅,AJAX請(qǐng)求以后又變白了。
Timer實(shí)現(xiàn)定時(shí)AJAX效果,原理分析。
UpdateProgress顯示“正在加載數(shù)據(jù)”。
AJAX Toolkit簡(jiǎn)介。
微軟異步組件:
1.拖拽ScriptManager一個(gè)。
2.可以拽多個(gè)UpdatePanel.
3.把ListView放到UpdatePanel中。
配合ObjectDataSource實(shí)現(xiàn)增刪改查。
4.演示在UpdatePanel中,放按鈕,做按鈕的點(diǎn)擊事件
在按鈕的點(diǎn)擊事件中執(zhí)行操作。
5.做一些Demo性演示。
6.放在UpdateProcess中的內(nèi)容就是當(dāng)服務(wù)器等待的時(shí)候顯示這個(gè)panel,當(dāng)接收到請(qǐng)求數(shù)據(jù)的時(shí)候則UpdateProcess就不顯示了。
微軟Ajax組件
-》講在前面:這樣提高了開(kāi)發(fā)效率,但是真實(shí)的執(zhí)行效率,并沒(méi)有提高
-》主要控件:在工具箱的“ajax擴(kuò)展”標(biāo)簽中,包含了基本的ajax控件
ScriptManager:放在頁(yè)面的最頂端,必須要有這個(gè)控件,才可以使用異步控件
一個(gè)頁(yè)面中只有一個(gè)ScriptManager控件
UpdatePanel:放在這個(gè)容器內(nèi)的內(nèi)容,都會(huì)進(jìn)行異步刷新
可以有多個(gè)UpdatePanel控件
UpdateProgress:用于顯示進(jìn)度,可以放置一張旋轉(zhuǎn)的圖片
Index.aspx
1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="t3_Ajax.Index" %> 2 3 <!DOCTYPE html> 4 5 <html xmlns="http://www.w3.org/1999/xhtml"> 6 <head runat="server"> 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 8 <title></title> 9 <style type="text/css"> 10 .auto-style1 { 11 width: 100px; 12 height: 100px; 13 } 14 </style> 15 </head> 16 <body> 17 <form id="form1" runat="server"> 18 <asp:ScriptManager ID="ScriptManager1" runat="server"> 19 </asp:ScriptManager> 20 <div> 21 <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 22 <ContentTemplate> 23 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> 24 <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 25 </ContentTemplate> 26 </asp:UpdatePanel> 27 <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"> 28 <ProgressTemplate> 29 <img alt="" class="auto-style1" src="images/loading.gif" /> 30 </ProgressTemplate> 31 </asp:UpdateProgress> 32 <br /> 33 <br /> 34 <br /> 35 <hr /> 36 <%=DateTime.Now.ToString() %> 37 </div> 38 </form> 39 </body> 40 </html>Index.aspx.cs
1 public partial class Index : System.Web.UI.Page 2 { 3 protected void Page_Load(object sender, EventArgs e) 4 { 5 6 } 7 8 protected void Button1_Click(object sender, EventArgs e) 9 { 10 Thread.Sleep(2000); 11 Label1.Text = DateTime.Now.ToString(); 12 } 13 }?
轉(zhuǎn)載于:https://www.cnblogs.com/ninghongkun/p/6363611.html
與50位技術(shù)專家面對(duì)面20年技術(shù)見(jiàn)證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的026-微软Ajax异步组件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【10】48. Rotate Image
- 下一篇: 条件异常处理和变量