简体   繁体   中英

Button click not working Using ASP.NET c#

In local working correctly, but when I am doing registration on liver server then some time registration is redirecting to successfully page and some time not redirecting, and also not getting any error message. The registration form is very big, so, I am not putting all design, code but I have taken code from every block. According to me panel are the problem may be, But another thing I had to observe if the page is not registration, then I reload again same page, then fill all details then its taking submission.

Page Load Code:

  BusinessLogic bl = new BusinessLogic();
BusinessObject bo = new BusinessObject();
protected void Page_Load(object sender, EventArgs e)
{
    HtmlGenericControl body = (HtmlGenericControl)Master.FindControl("MasterpageID");
    body.Attributes.Add("class", "fifth");

    //to restore password field when page refreshes
    txt_Password.Attributes.Add("value", txt_Password.Text);



}

Design Code:

Nationality:<asp:DropDownList ID="ddl_Nationality" runat="server" CssClass="dropdown" AppendDataBoundItems="true"
            AutoPostBack="true" OnSelectedIndexChanged="ddl_Nationality_SelectedIndexChanged">
                <asp:ListItem Text="Select" Value="0"></asp:ListItem>
                    <asp:ListItem Text="Indian" Value="Indian"></asp:ListItem>
                    <asp:ListItem Text="Expatriate" Value="Expatriate"></asp:ListItem>
          </asp:DropDownList>


    Title: <asp:DropDownList ID="ddl_Title" runat="server" CssClass="dropdown" AppendDataBoundItems="true">
    <asp:ListItem Text="Select" Value="0"></asp:ListItem>
        <asp:ListItem Text="Mr." Value="Mr."></asp:ListItem>

        </asp:DropDownList>

    Name:  <asp:TextBox ID="txt_Name" runat="server" CssClass="textfield_new1" MaxLength="20"></asp:TextBox>

    </ContentTemplate>
    </asp:UpdatePanel>


     <asp:UpdatePanel ID="UpdatePanel3" runat="server">
      <ContentTemplate>

    <table>
    <tr>
    <td>
    Country:    <asp:DropDownList ID="ddl_Country" runat="server" CssClass="dropdown">
            <asp:ListItem Text="Select" Value="0"></asp:ListItem>
                  </asp:DropDownList>

    </td>

    </tr>

    </table>

    </ContentTemplate>
    </asp:UpdatePanel>


    <table>
    <tr>
    <td>
        <asp:UpdatePanel ID="UpdatePanel5" runat="server" >
                <ContentTemplate>
                   Total Experience:        <asp:DropDownList ID="ddl_years" runat="server" AutoPostBack="true" CssClass="Exp"
                   OnSelectedIndexChanged="ddl_years_SelectedIndexChanged">
                       <asp:ListItem Value="0">Year</asp:ListItem>
               <asp:ListItem Value="1">0</asp:ListItem>
                    <asp:ListItem Value="2">1</asp:ListItem>
                        <asp:ListItem Value="3">2</asp:ListItem>
                        <asp:ListItem Value="4">3</asp:ListItem>

             </asp:DropDownList>
                  <asp:DropDownList ID="ddl_months" runat="server" CssClass="Exp"
               Enabled="false">
                   <asp:ListItem Selected="True" Value="0">Month</asp:ListItem>
              <asp:ListItem Value="1">0</asp:ListItem>

              </asp:DropDownList>
               </ContentTemplate>
                </asp:UpdatePanel>
             </td> </tr>

    </table>


        <table>
    <tr>
    <td>
            <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                <ContentTemplate>
        <cc1:CaptchaControl ID="CaptchaControl1" runat="server" CaptchaBackgroundNoise="None"
            CaptchaHeight="40" CaptchaLength="5" CaptchaLineNoise="None" CaptchaMaxTimeout="240" 
        CaptchaMinTimeout="5" FontColor="111, 109, 85" Width="325px" CaptchaWidth="300"
        CssClass="textarea_captha" />

            </ContentTemplate>
        </asp:UpdatePanel>

    </td></tr>
        <tr><td>
    Enter Text as you See:<asp:TextBox ID="txtCaptcha" runat="server" CssClass="textfield_new1"></asp:TextBox>

        </td></tr>

    </table>

    <table>
    <tr><td>

    <asp:LinkButton ID="imgbtn_Submit" runat="server" ValidationGroup="reg" CssClass="submitbtn"

    </td></tr>
    </table>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
                <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/spacer.gif" />
                <cc1:ModalPopupExtender ID="ModalPopupExtender1" TargetControlID="ImageButton1" PopupControlID="Pnl_popup1"
                BackgroundCssClass="modalBackground" Drag="true" PopupDragHandleControlID="Pnl_popup1"
                                                    runat="server">
                    </cc1:ModalPopupExtender>
                    <asp:Panel ID="Pnl_popup1" runat="server">
                                                //pop design code is here

                                                    </asp:Panel>
                </ContentTemplate>
                </asp:UpdatePanel>

Thanks in advance.

Your update panels are making the problems in redirection. Please note that, update panel is only used for AJAX request. It will post only selected panel data. So it will not make sense to add Update panel, when you want redirection from one page to another.

Remove unnecessary update panels and try to do it. It will help you.

在按钮中添加OnClick事件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM