using update panel do sync job , update UI control async
2014-01-07 17:50
225 查看
Scenario :
1.click submit disable button ,start job
2.once job done , enable submit button
Here is the implementation :
Aspx page Code :
Step 1: add update panel and script manager
Step 2: add javascript
Step 3:
Code behind :
1.click submit disable button ,start job
2.once job done , enable submit button
Here is the implementation :
Aspx page Code :
Step 1: add update panel and script manager
<form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="AsynUpdatePanel" runat="server" UpdateMode="Conditional"> <ContentTemplate> <!--<span class="code-comment"> Here on click is a long running operation e.g. 30 secs --></span> <asp:Button ID="Submit" runat="server" OnClick="Submit_Click" Text="Submit" /> </ContentTemplate> </asp:UpdatePanel> </form>
Step 2: add javascript
<script type="text/javascript"> Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(startRequest); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest); function startRequest(sender, e) { document.getElementById("<%=Submit.ClientID%>").disabled = true; } function endRequest(sender, e) { document.getElementById("<%=Submit.ClientID%>").disabled = false; } </script>
Step 3:
Code behind :
//Simulate a long time task protected void Submit_Click(object sender, EventArgs e) { Thread.Sleep(2000); }
相关文章推荐
- 第五篇: UpdatePanel 控件--RegisterAsyncPostBackControl方法
- 第五篇: UpdatePanel 控件--RegisterAsyncPostBackControl方法
- LINQ to SQL系列Part 5 - Binding UI using the ASP:LinqDataSource Control
- Loading UserControl Dynamically in UpdatePanel 【transfer]
- Tip/Trick: Cool UI Templating Technique to use with ASP.NET AJAX for non-UpdatePanel scenarios
- 从Atlas到Microsoft ASP.NET AJAX(8) - UpdatePanel Control
- JqueryUI dialog model和asp_UpdatePanel 例子
- 类型“System.Web.UI.UpdatePanel”不具有名为“DropDownList”的公共属性,解决方法
- An extender can't be in a different UpdatePanel than the control it extends
- Easily refresh an UpdatePanel, using JavaScript
- AjaxControlToolkit 微软出的ajax.net 工具使用教程六 使用UpdatePanel控件(一)
- UpdatePanel中动态加入AsyncPostBackTrigger出现的问题
- ASP.NET AJAX Roadmap--Getting Started (4): Introduction to the UpdatePanel Control
- Asp.net UpdatePanel在asyncpostback后页面标题丢失的BUG解决
- 【转载】LINQ to SQL (Part 5 - Binding UI using the ASP:LinqDataSource Control)
- AjaxControlToolkit 微软出的ajax.net 工具使用教程七 使用UpdatePanel控件(二)
- *Using the ASP.NET Panel Control...
- UpdatePanel Control
- UpdatePanel and UpdateProgress Position Control
- 从Atlas到Microsoft ASP.NET AJAX(8) - UpdatePanel Control