Click here to Skip to main content
11,705,763 members (53,726 online)
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>

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 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 213
1 Sergey Alexandrovich Kryukov 170
2 Inimicos 60
3 ProgramFOX 50
4 Richard MacCutchan 45
0 OriginalGriff 9,053
1 Sergey Alexandrovich Kryukov 8,347
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 10 Jul 2013
Copyright © CodeProject, 1999-2015
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