026-微软Ajax异步组件
ASP.Net中內置的簡化AJAX開發的控件UpdatePanel
放入ScriptManager,將要實現AJAX效果的控件放到UpdatePanel中即可。
UpdatePanel原理探秘,用HttpWatch看。
只把需要無刷新更新的部分放到UpdatePanel中。
UpdatePanel用來實現一些對性能要求不高的需求非常方便。
從原理分析為什么在客戶端把TextBox變紅,AJAX請求以后又變白了。
Timer實現定時AJAX效果,原理分析。
UpdateProgress顯示“正在加載數據”。
AJAX Toolkit簡介。
微軟異步組件:
1.拖拽ScriptManager一個。
2.可以拽多個UpdatePanel.
3.把ListView放到UpdatePanel中。
配合ObjectDataSource實現增刪改查。
4.演示在UpdatePanel中,放按鈕,做按鈕的點擊事件
在按鈕的點擊事件中執行操作。
5.做一些Demo性演示。
6.放在UpdateProcess中的內容就是當服務器等待的時候顯示這個panel,當接收到請求數據的時候則UpdateProcess就不顯示了。
微軟Ajax組件
-》講在前面:這樣提高了開發效率,但是真實的執行效率,并沒有提高
-》主要控件:在工具箱的“ajax擴展”標簽中,包含了基本的ajax控件
ScriptManager:放在頁面的最頂端,必須要有這個控件,才可以使用異步控件
一個頁面中只有一個ScriptManager控件
UpdatePanel:放在這個容器內的內容,都會進行異步刷新
可以有多個UpdatePanel控件
UpdateProgress:用于顯示進度,可以放置一張旋轉的圖片
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 }?
轉載于:https://www.cnblogs.com/ninghongkun/p/6363611.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的026-微软Ajax异步组件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【10】48. Rotate Image
- 下一篇: 条件异常处理和变量