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
<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);
}
分享到:
相关推荐
The Half-Sync/Half-Async architectural pattern decouples synchronous tasks from asynchronous tasks in complex concurrent systems.
async reset to sync reset
执行扩展 AsyncJob 类并定义 syncjob() 方法以输出字符串或文件类型的对象。 AsyncJob 会将此输出上传到 S3,并在进程运行时提供管理监控。 AsyncJob Django 设置: ASYNCJOB_S3_...
B27A_Fortis_Flash_512Gb_1Tb_2Tb_4Tb_Async_Sync_NAND_Datasheet
Synchronous Resets? Asynchronous Resets? I am so confused! How will I ever know which to use?
1、通过dispatch_barrier_(a)sync添加的block会等待前边所有的block执行完(不包括回调)才执行。 2、在其后添加的block会在dispatch_barrier_(a)sync添加的block执行完之后(不包括回调)再执行; 不同点: 1、...
例子import { doSync , AsyncFn , JSONObject } from 'do-sync' ;interface resizeOpts extends JSONObject { width : number , height : number}interface resizeRet extends JSONObject { width : number , height...
AsyncCalls(异步调用函数),Delphi异步调用函数的单元和例子
网上async with和async for的中文资料比较少,我把PEP 492中的官方陈述翻译一下。 异步上下文管理器”async with” 异步上下文管理器指的是在enter和exit方法处能够暂停执行的上下文管理器。 为了实现这样的功能,...
If you already own a PC and have ...and to make sure that we have missed nothing we will also open it up,though only in our imagination.You will see what you can do with a PC and the best way to use it.
Visual Studio C++ Opencv ASYNC
Async, await control flow for Swift..zip,异步,等待swift的控制流。
Android Async-Http Demo
这是一个高性能的TCP服务器,其中使用了异步socket的方式。
很好用的Async32,不用多说,你用了就知道啦。
Example for binding an ObservableCollection to a ListView and using async await Task to update the data
async/await异步处理
HTTP requests happen outside the UI thread Requests use a threadpool to cap concurrent resource usage GET/POST params builder (RequestParams) Multipart file uploads with no additional third party ...
Apress - Pro Async Programming in .NET
async2sync 将初步操作转换成瀑布同步形式,适应前端有顺序的io操作 ♡ 因为没有发布的npm,以npm私包存放的,所以以私包方式加载npm install git + ssh://git@github.com:canwhite / async2sync.git使用的时候...