Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
this is aspx page
XML
<div class="detail_label">
                <asp:Button ID="btn_purchase" runat="server" Text="Add To Cart" OnClick="btn_purchase_Click" /></div>
          <div class="parentdiasble" runat="server">
            </div>
                <div id="popupdiv" runat="server" style="display: none" >

                            <table>
                                <tr>
                                    <td><span class="txt">Username: </span><span class="redstar">*</span></td>
                                    <td>
                                        <asp:TextBox ID="txtUserName" runat="server" placeholder=" UserName"
                                            Width="186px"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="rfvUserName" runat="server"
                                            ErrorMessage="Please enter  User Name" ControlToValidate="txtUserName" ValidationGroup="Login"
                                            Display="Dynamic" ForeColor="Red"></asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td><span class="txt">Password: <span class="redstar">*</span> &nbsp;&nbsp;</span></td>
                                    <td>
                                        <asp:TextBox ID="txtPwd" runat="server" TextMode="Password" placeholder=" Password" Width="186px"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                                            ControlToValidate="txtPwd" Display="Dynamic" ValidationGroup="Login"
                                            ErrorMessage="Please enter Password" ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td>
                                        <asp:Button ID="btnSubmit" ValidationGroup="Login" runat="server" Text="Login" OnClick="btnSubmit_Click"/>
                                        <asp:Button ID="btnclose"  runat="server" Text="Cancel" CausesValidation="false" style="height: 26px" /></td>
                                </tr>

                                <tr>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                </tr>

                            </table>
                      </div>

this is for c# code behind
C#
protected void btnSubmit_Click(object sender, EventArgs e)
    {
        SqlCommand cmd = new SqlCommand("popupid_sp", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@name", txtUserName.Text);
        Class2.userid = Convert.ToInt32(cmd.ExecuteScalar());
        HttpCookie cookie = new HttpCookie("useridCookie");
        cookie["idCookie"] = Convert.ToString(Class2.userid);
        Response.Cookies.Add(cookie);
        Context.Server.Transfer("~/webpages/detail_page.aspx");
        
       
    }


  
    protected void btn_purchase_Click(object sender, EventArgs e)
    {
        if (Request.Cookies["idCookie"] == null)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "Popup", "popuplogin()", true);
        }
        else
        {
            Context.Server.Transfer("~/webpages/detail_page.aspx");

        }
this is for javascript
function popuplogin()
       {

              $("#popupdiv").dialog({
               title: "login",
               width: 430,
               height: 250,
               modal: true,
               buttons: {
                   //close: function () {
                   //    __dopostback('btnsubmit', '');
                   //}
               }

           });

       }


button which is in inside of the popupdiv is not firing
kindly response
Posted
Updated 29-Sep-15 4:07am
v2
Comments
Richard Deeming 29-Sep-15 9:59am    
REPOST
You have already posted this question:
http://www.codeproject.com/Questions/1034355/popup-button-click-event-is-not-firing-while-popup[^]

To update your question with missing details, use the "Improve question" button at the bottom of your question. DO NOT repost the same question!
Sreekanth Mothukuru 29-Sep-15 13:57pm    
There are two buttons in popupdiv.. which one is not working? Have you inspected for the same in f12 console what does it say?
j snooze 29-Sep-15 17:25pm    
Try taking the required field validators out and see if the page posts back. Then you know those are what are stopping you from posting back.
aarif moh shaikh 1-Oct-15 5:50am    
look your Css Positioning ..

1 solution

Hi shanmugaprabu198512,

I think Your Second Button within popup will only fire if your validation Group Login validates successfully.
If your validation not succeeds then your button will not fire Click event.

To Check that just remove your ValidationGroup="Login" and add CausesValidation="false" to Button and click . It will fire its click event now.

So the problem is with validation if it passess button will do their job otherwise its event prevented by validation rule.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900