-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)单击按钮时,应禁用该按钮或单击按钮时加载图像位于页面中心。

4

1 回答 1

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>
于 2013-06-01T13:33:19.243 回答