Click here to Skip to main content
15,912,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error 3 'Button2_Click' is not a member of 'ASP.newmember_aspx'. C:\Users\dr.apple\Documents\Visual Studio 2010\WebSites\WebSite2\newmember.aspx 45

although i have the method in inside the class and that is the code:

C#
protected void Button2_Click(object sender, EventArgs e) 
{ SqlConnection con = new SqlConnection(Database.ConnectionString);
 try {
 con.Open(); SqlCommand cmd = new SqlCommand("select isnull(max(mid),0)+1 from members", con);
 int mid = (int)cmd.ExecuteScalar();
 SqlCommand cmd1 = new SqlCommand("select isnotnull from members", con); 
string mname = (string)cmd1.ExecuteScalar();
 SqlCommand cmd3 = new SqlCommand("select isnotnull from members", con);
 Char password = (char)cmd3.ExecuteScalar();
 SqlCommand cmd4 = new SqlCommand("select isnotnull from members", con);
 string email = (string)cmd4.ExecuteScalar();
 cmd.CommandText = "insert into members values(@mid,@name,@password,@email)"; cmd.Parameters.Add("@mid", SqlDbType.Int).Value = mid; cmd.Parameters.Add("@mname", SqlDbType.VarChar, 50).Value = mname; cmd.Parameters.Add("@password", SqlDbType.VarChar, 10).Value = password; cmd.Parameters.Add("@email", SqlDbType.VarChar, 40).Value = email; cmd.ExecuteNonQuery(); HttpContext.Current.Trace.Write("Member has been added successfully with ID = " + mid); } catch (Exception ex) { HttpContext.Current.Trace.Write("error" + ex.Message); } finally { con.Close(); } } }
Posted
Updated 23-Dec-12 10:58am
v2

I believe your problem is that the designer doesn't have Button2_Click added.
Try copying your code above, deleting it, then add the method again and paste the code. I don't know much about ASP.NET, but best of luck.
 
Share this answer
 
roblem is that the designer doesn't have Button2_Click added.
Try copying your code above, deleting
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900