Click here to Skip to main content
13,042,630 members (84,256 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I have a popup modal using asp.net and it does appear but when i click btnOkay instead of navigating to
OnClick="btnOkay_Click"
it do nothing

Here is my code
<div>
        <asp:scriptmanager id="ScriptManager1" runat="server">
</asp:scriptmanager>
 

 
<cc1:modalpopupextender id="ModalPopupExtender1"  runat="server" 
	cancelcontrolid="btnCancel" okcontrolid="btnOkay" 
	targetcontrolid="btnVote" popupcontrolid="Panel1" 
	popupdraghandlecontrolid="PopupHeader" drag="true" 
	backgroundcssclass="ModalPopupBG">
</cc1:modalpopupextender>
 
        <asp:Panel ID="Panel1" Style="display: none;" runat="server">
            <div class="HellowWorldPopup">
                <div class="PopupHeader" id="PopupHeader">
                    <h3>Read before you vote!</h3>
                </div>
                <div class="PopupBody">
                    <p>Are you sure you wanna procede</p>
                </div>
 
                <div class="Controls">
                      
                    
                    <asp:Button ID="btnOkay" OnClick="btnOkay_Click" runat="server" Text="Agree" />
                    <asp:Button ID="btnCancel" runat="server" Text="Decline" />
 
                </div>
 
            </div>
        </asp:Panel>
    </div>


Here is my
OnClick="btnOkay_Click"
code

 protected void btnOkay_Click(object sender, EventArgs e)
    {
 
        string sql = "SELECT * FROM STUDENT WHERE Student_Number = '" + Session["name"].ToString() + "'";
        SqlConnection conn = new SqlConnection(ConnString);
        SqlCommand cmd = new SqlCommand(sql, conn);
        if (conn.State == ConnectionState.Closed)
        {
            conn.Open();
        }
        DataTable dt = new DataTable();
 
        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
 
        adapter.Fill(dt);
 
        if (dt.Rows[0]["Student_Nationality"].ToString() == "South African" && dt.Rows[0]["Student_Accomodation"].ToString() == "On Campus")
        {
            Response.Redirect("~/VoteGeneral.aspx");
        }
 
        else if (dt.Rows[0]["Student_Nationality"].ToString() == "South African" && dt.Rows[0]["Student_Accomodation"].ToString() == "Off Campus")
        {
            Response.Redirect("~/VoteOppidani.aspx");
        }
        else if (dt.Rows[0]["Student_Nationality"].ToString() == "Non South Afircan" && dt.Rows[0]["Student_Accomodation"].ToString() == "On Campus")
        {
            Response.Redirect("~/VoteInternational.aspx");
        }
        else if (dt.Rows[0]["Student_Nationality"].ToString() == "Non South Afircan" && dt.Rows[0]["Student_Accomodation"].ToString() == "Off Campus")
        {
            Response.Redirect("~/Vote.aspx");
        }
        else
        {
            Response.Write("Sorry You can not vote");
        }
    }
Posted 9-Jul-13 23:22pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

It seems that the click event of OK or CANCEL button's of modalpopupextender does not get fired.

Try removing the :

okcontrolid="btnOkay"


from modalpopupextender and check if it works.
  Permalink  
Comments
210032278 10-Jul-13 7:13am
   
Thanx, its wekin perfectly.... :-) -RSA
Priyanka7777 10-Jul-13 7:30am
   
Im glad that it helped you!!!

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


Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 10 Jul 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100