Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL
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 10-Jul-13 0:22am

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 at 10-Jul-13 7:13am
   
Thanx, its wekin perfectly.... :-) -RSA
Priyanka7777 at 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
0 OriginalGriff 520
1 Maciej Los 290
2 Richard MacCutchan 265
3 BillWoodruff 265
4 Suraj Sahoo | Coding Passion 155
0 OriginalGriff 8,764
1 Sergey Alexandrovich Kryukov 7,437
2 DamithSL 5,639
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411028.1 | Last Updated 10 Jul 2013
Copyright © CodeProject, 1999-2014
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