2013-06-30 33 views
2

我有一個用.ascx編寫的代碼,也用於登錄按鈕。在瀏覽器進入用戶頁面之前如何顯示loading.gif? 這裏是登錄按鈕代碼:如何在單擊登錄按鈕時顯示loading.gif?

<div class="login"> 
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate>  
    <asp:Button ID="btnlogin" runat="server" Text="Log In" border="0" 
    style="width:47px; height:20px;Background-color:#24b1d7; float:right; text-align:center; cursor:pointer; font-family:'Lucida Grande',Tahoma,Verdana,Arial,sans-serif; border:0px; color:#FFFFFF; font-weight:bold; font-size:11px; padding: 1px 0 2px; line-height:0px;" />            
    </ContentTemplate> 
</asp:UpdatePanel> 

+0

更新面板更新時可能出現的[ASP.NET顯示「正在加載...」消息的副本](http://stackoverflow.com/questions/7704171/asp-net-display-loading-message-while-update - 面板-是更新) – Aristos

回答

1

使用的onClick方法,改變按鈕的文字loading.gif,或使用標籤,其文本是空的,但是當按鈕點擊,文字變成圖片loading.gif。然後,當用戶被驗證時,給這個方法一個成功的事件,在這個點上,如果它失敗了,文本變回原來的,並且顯示一條消息「Login Unsuccessful」,或者另一方面,如果成功,則頁面被重定向到登錄頁面。