Click here to Skip to main content
12,077,333 members (43,684 online)
Rate this:
 
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>

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 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
Web04 | 2.8.160212.1 | Last Updated 10 Jul 2013
Copyright © CodeProject, 1999-2016
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