Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET buttons
protected void Button1_Click(object sender, EventArgs e)
   {   count++;
       int noofcount = count;
       Label6.Text = noofcount.ToString();
       if (noofcount > 5)
       {    string ch = "Attacker";
 
           
                     con = new SqlConnection("Data Source=Database; Initial Catalog=firecol; User Id=sa; Pwd=password");
           con.Open();
 
           cmd = new SqlCommand("update normaluser set type='" + ch + "' where username='" + Label5.Text + "'", con);
           cmd.ExecuteNonQuery();
           con.Close();
           count=0;
       }
       else
 {String bl = "", la = "";
           con = new SqlConnection("Data Source=FABSYS39\\SQLEXPRESS; Initial Catalog=firecol; User Id=sa; Pwd=saadmin");
 
           con.Open();
 cmd = new SqlCommand("Insert into questions Values('" + Label5.Text + "','" + ddldetails.SelectedItem.Text + "','" + DropDownList2.SelectedItem.Text + "','" + TextBox1.Text + "','" + la + "','" + bl + "')", con);
           cmd.ExecuteNonQuery();
           con.Close();
           Label4.Visible = true;
       }
 

i wanna clear this button clcik count while i leaving in this page....how can i clear that??? pls help me???
Posted 18-Nov-12 22:51pm
Deenuji3.8K
Edited 18-Nov-12 23:10pm
v2

1 solution

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

Solution 1

You can keep a flag that indicates you to reset. Then In the page load event check IsPostBack, if it is not true, not if your flag suggests you to reset count, reset it.
 
Wait a minute, Why are you giving your SQL server name, id, password in open?
 
Are you not scared !!!
 
Milind
  Permalink  
Comments
deenujii at 19-Nov-12 5:29am
   
tat password and id s fake ly sir....
deenujii at 19-Nov-12 5:29am
   
now it's working correctly.... thank u sir....

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

  Print Answers RSS
0 Maciej Los 225
1 CHill60 170
2 Manfred R. Bihy 170
3 _Amy 155
4 Sergey Alexandrovich Kryukov 144
0 OriginalGriff 7,320
1 Sergey Alexandrovich Kryukov 6,043
2 Maciej Los 3,754
3 Peter Leow 3,448
4 CHill60 2,572


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 19 Nov 2012
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