C
Columbia Pike
Hi,
I'm trying to have a login page; after logging in the user has to see the list of SQL Server Databases available to him/her. I'm always getting the error
'ASP.login_aspx' does not contain a definition for 'btnSignIn_Click'
I have the btnSignIn_Click function defined in a codebehind .cs file - The file name is Connect.aspx.cs. I made a DLL and have that DLL in the Bin subfolder (Bin\Connect.dll).
Here's the command I used for making the dll -
C:\Inetpub\wwwroot\xml\dotnet>csc /out:Connect.dll /r:System.dll,System.web.dll,System.Data.dll /t:library Connect.aspx.cs
Here's the code I wrote for Connect.aspx.cs
/**********************************************************************************/
using System;
using System.Web;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlTypes;
/// <summary>
/// Description of Class1.
/// </summary>
public class Connect : System.Web.UI.Page
{
public System.Web.UI.WebControls.TextBox txtLogin;
public System.Web.UI.WebControls.RequiredFieldValidator RFVLogin;
public System.Web.UI.WebControls.TextBox txtPassword;
public System.Web.UI.WebControls.RequiredFieldValidator RFVPassword;
public System.Web.UI.WebControls.Button btnSignIn;
public System.Web.UI.WebControls.Label Msg;
protected void Page_Load(object sender, EventArgs e){
if(!IsPostBack) {
Msg.Text = "Welcome. Enter your SQL Server user-name and password.";
}
}
protected void btnSignIn_Click(object Sender, EventArgs e){
if(Page.IsValid){
Session["uid"]=txtLogin.Text;
Session["pwd"]=txtPassword.Text;
SqlConnection conn = new SqlConnection("server=localhost;uid=" + txtLogin.Text + ";pwd=" + txtPassword.Text);
try {
conn.Open();
SqlCommand strsql = new SqlCommand("SELECT name FROM master.dbo.sysdatabases WHERE has_dbaccess(name) = 1 ORDER BY name ", conn);
SqlDataReader myreader;
myreader = strsql.ExecuteReader();
}
catch(SqlException sqlerr) {
Msg.Text=sqlerr.ToString();
}
}
}
}
/**********************************************************************************/
<pre>
<!--Here's the code page from where I'm referring this codebehind part. login.aspx ------------>
<%@ Page Language="c#" codebehind="Connect.aspx.cs" Trace="True" %>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<form runat="server">
<h2>Login Page
</h2>
<hr size="1" />
<table>
<tbody>
<tr>
<td>
Username:</td>
<td>
<asp:TextBox id="txtLogin" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator id="RFVLogin" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="UserName"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Password:</td>
<td>
<asp:TextBox id="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator id="RFVPassword" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="UserPass"></asp:RequiredFieldValidator>
</td>
</tr>
</tbody>
</table>
<asp:Button id="btnSignIn" onclick="btnSignIn_Click" Text="Sign In" Runat="server"></asp:Button>
<p>
<asp:Label id="Msg" runat="server" forecolor="red"></asp:Label>
</p>
</form>
</body>
</html>
<!---------------------------------------------------->
</pre>
Can you please tell me what is causing that error ? I've been breaking my head asking everyone, and Googling everything I can.
Thank you.
I'm trying to have a login page; after logging in the user has to see the list of SQL Server Databases available to him/her. I'm always getting the error
'ASP.login_aspx' does not contain a definition for 'btnSignIn_Click'
I have the btnSignIn_Click function defined in a codebehind .cs file - The file name is Connect.aspx.cs. I made a DLL and have that DLL in the Bin subfolder (Bin\Connect.dll).
Here's the command I used for making the dll -
C:\Inetpub\wwwroot\xml\dotnet>csc /out:Connect.dll /r:System.dll,System.web.dll,System.Data.dll /t:library Connect.aspx.cs
Here's the code I wrote for Connect.aspx.cs
/**********************************************************************************/
using System;
using System.Web;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlTypes;
/// <summary>
/// Description of Class1.
/// </summary>
public class Connect : System.Web.UI.Page
{
public System.Web.UI.WebControls.TextBox txtLogin;
public System.Web.UI.WebControls.RequiredFieldValidator RFVLogin;
public System.Web.UI.WebControls.TextBox txtPassword;
public System.Web.UI.WebControls.RequiredFieldValidator RFVPassword;
public System.Web.UI.WebControls.Button btnSignIn;
public System.Web.UI.WebControls.Label Msg;
protected void Page_Load(object sender, EventArgs e){
if(!IsPostBack) {
Msg.Text = "Welcome. Enter your SQL Server user-name and password.";
}
}
protected void btnSignIn_Click(object Sender, EventArgs e){
if(Page.IsValid){
Session["uid"]=txtLogin.Text;
Session["pwd"]=txtPassword.Text;
SqlConnection conn = new SqlConnection("server=localhost;uid=" + txtLogin.Text + ";pwd=" + txtPassword.Text);
try {
conn.Open();
SqlCommand strsql = new SqlCommand("SELECT name FROM master.dbo.sysdatabases WHERE has_dbaccess(name) = 1 ORDER BY name ", conn);
SqlDataReader myreader;
myreader = strsql.ExecuteReader();
}
catch(SqlException sqlerr) {
Msg.Text=sqlerr.ToString();
}
}
}
}
/**********************************************************************************/
<pre>
<!--Here's the code page from where I'm referring this codebehind part. login.aspx ------------>
<%@ Page Language="c#" codebehind="Connect.aspx.cs" Trace="True" %>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<form runat="server">
<h2>Login Page
</h2>
<hr size="1" />
<table>
<tbody>
<tr>
<td>
Username:</td>
<td>
<asp:TextBox id="txtLogin" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator id="RFVLogin" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="UserName"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Password:</td>
<td>
<asp:TextBox id="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator id="RFVPassword" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="UserPass"></asp:RequiredFieldValidator>
</td>
</tr>
</tbody>
</table>
<asp:Button id="btnSignIn" onclick="btnSignIn_Click" Text="Sign In" Runat="server"></asp:Button>
<p>
<asp:Label id="Msg" runat="server" forecolor="red"></asp:Label>
</p>
</form>
</body>
</html>
<!---------------------------------------------------->
</pre>
Can you please tell me what is causing that error ? I've been breaking my head asking everyone, and Googling everything I can.
Thank you.