HI All, im working on a project that uses asp.net to send information to a mssql server. The problem im running into is that when i try to debug the page, I get: 'ClickSave' is not a member of 'ASP.default_aspx'.
How Do I fix this??
Heres My html code(default.aspx):
<html>
<head></head>
<body>
<form id="form1" runat="server">
<div>
<table width="300px" >
<tr>
<td>First Name</td>
<td>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td >Last Name</td>
<td>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>User Name</td>
<td>
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Password</td>
<td>
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Email Address</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnSave" runat="server" Text="Save" onclick="ClickSave" />
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Label ID="lblError" runat="server" Text=""></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
ASP code(default.aspx.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using System.Data;
namespace Mysqlpart1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ClickSave(object sender, EventArgs e)
{
try
{
string cnnString = "Server=localhost;Port=3306;Database=ci_series;Uid=xxxxx;Pwd=xxxxx";
MySqlConnection connection = new MySqlConnection(cnnString);
string cmdText = "INSERT INTO membership (first_name ,last_name ,username ,password ,";
cmdText += "email_address)VALUES (first_name ,last_name ,username ,password ,email_address);";
MySqlCommand cmd = new MySqlCommand(cmdText, connection);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add("?first_name", MySqlDbType.VarChar).Value = txtFirstName.Text;
cmd.Parameters.Add("?last_name", MySqlDbType.VarChar).Value = txtLastName.Text;
cmd.Parameters.Add("?username", MySqlDbType.VarChar).Value = txtUserName.Text;
cmd.Parameters.Add("?password", MySqlDbType.VarChar).Value = txtPassword.Text;
cmd.Parameters.Add("?email_address", MySqlDbType.VarChar).Value = txtEmail.Text;
connection.Open();
int result = cmd.ExecuteNonQuery();
lblError.Text = "Data Saved";
}
catch (Exception ex)
{
lblError.Text = ex.Message;
}
}
}
}