Why does a button event function run during a page reload in ASP.NET?

hurebixewu

New Member
\[code\]public partial class Stats : System.Web.UI.Page{ public SqlDataReader DataReader; public SqlCommand Command; string queryString = ("INSERT INTO UserData (UserProfileID, ConfidenceLevel, LoveLevel, HappinessLevel) VALUES ('a051fc1b-4f51-485b-a07d-0f378528974e', 1, 1, 1);"); protected void Page_Load(object sender, EventArgs e) { LabelUserID.Text = Membership.GetUser().ProviderUserKey.ToString(); } protected void Button1_Click(object sender, EventArgs e) { MySqlConnection database = new MySqlConnection(); database.CreateConn(); Command = new SqlCommand(queryString, database.Connection); Command.ExecuteNonQuery(); }}\[/code\]Not sure I understand why Button1_Click() is executing on a page reload.
I put in a break point in the function and it does hit it as well as update the database.Any suggestions?Thank You.
 
Back
Top