2013-06-01 172 views
-2

这是代码:上按钮点击执行此操作

protected void btnProceed_Click(object sender, EventArgs e) 
{ 
    if (!Page.IsValid) 
    { 
     return; 
    } 

    MembershipCreateStatus createstatus; 
    UserDetails us = new UserDetails(); 

     MembershipUser Newuser = Membership.CreateUser(txtusrname.Text, txtpassword.Text, txtemailid.Text, "Question", "Answer", true, out createstatus); 

     if (Newuser != null && createstatus == MembershipCreateStatus.Success) 
     { 
      if (RdoAuthorReviewer.SelectedValue =="Author") 
      { 
       Roles.AddUserToRole(txtusrname.Text, "Author"); 
      } 

      int NoOfRecordsAffected = us.createUser(); 

      try 
      { 
       if (NoOfRecordsAffected > 0) 
       { 
        Mail.sendmail(); 
       } 
       else 
       { 
        Response.Redirect("SignUp-Error.aspx",true); 
       } 

      } 
     } 
    } 
} 

在ASPX页面按钮代码:

 <asp:Button ID="btnProceed" runat="server" CssClass="button notransitions" Text="Register User and Send Letter" ValidationGroup="reqGroup" onclick="btnProceed_Click"      TabIndex="16" style="width:303px; margin-top:15px;" /> 

我的要求:

1)在单击该按钮应禁用或当按钮被点击时,加载图像进入页面的中心。

+0

对不起!你的形象在哪里?你能提供一些额外的细节吗? – 2013-06-01 10:40:09

+0

我已经厌倦了这一点。请参阅此链接我也累了:http://www.malsup.com/jquery/block/,但它不起作用。只需提供我的代码,我按下提交按钮和加载图像来到图像的中心。我无法执行那 – Himanshu

+0

有很多插件的。哪一个是你用的? – 2013-06-01 10:45:49

回答

0

你可以实现你的“加载图像来在页面中心”使用Free AjaxControlToolkit或任何其他基于Ajax的工具情况下,如果你已经拥有它们。

您将需要使用AjaxLoadingPanelAjaxManager。 它会为您的情况看起来的例子:

<ajax:AjaxManager ID="AjaxManager1" runat="server"> 
     <AjaxSettings> 
     <ajax:AjaxSetting AjaxControlID="btnProceed"> 
        <UpdatedControls> 
         <ajax:AjaxUpdatedControl ControlID="btnProceed" LoadingPanelID="AjaxLoadingPanel1" /> 
         <ajax:AjaxUpdatedControl ControlID="AnythingElseID" LoadingPanelID="AjaxLoadingPanel1" /> <%-- For example if you have specified a whole page's id you can use it here to block all page or write any specific control's id's you want to block--%> 
         <ajax:AjaxUpdatedControl ControlID="AnythingElseIDWhereImgWillbeShown" LoadingPanelID="AjaxLoadingPanel2" /> <%-- Add update control with loadingpanel2 only once on the page if you want only 1 loading image--%> 
        </UpdatedControls> 
       </ajax:AjaxSetting> 
    </AjaxSettings> 
</ajax:AjaxManager> 

<ajax:AjaxLoadingPanel ID="AjaxLoadingPanel1" runat="server" Transparency="1" HorizontalAlign="Center"></ajax:AjaxLoadingPanel> 
<ajax:AjaxLoadingPanel ID="AjaxLoadingPanel2" runat="server" Transparency="1" HorizontalAlign="Center"> 
    <div style="margin-top:100px"> <%-- You can specify where to show your image from the starting place of control for which you will specify this panel in updatecontrol--%> 
    <asp:Image ID="Image1" runat="server" ImageUrl="loading.gif"></asp:Image> 
    </div> 
    </ajax:AjaxLoadingPanel> 
+0

谢谢它的工作原理 – Himanshu