按钮单击执行此操作

时间:2013-06-01 10:36:56

标签: c# asp.net

这是代码:

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

1 个答案:

答案 0 :(得分:0)

如果您已经拥有它们,则可以使用Free AjaxControlToolkit或任何其他 基于Ajax的工具包 来实现“加载图像位于页面中心”方案

您需要使用 AjaxLoadingPanel AjaxManager 。 您的案例的示例:

<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>