473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

'ASP.login_aspx' does not contain a definition for 'btnSignIn_Click' - I have the function..then why?

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.

Nov 18 '05 #1
5 8705
You have to rebuild the cs file and copy the builded .dll file in the bin
sub folder again

Regards
Martin

"Columbia Pike" <wh******@whatever.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
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.

Nov 18 '05 #2
If you use OnClick attribute in the page's HTML view, the name is expected
to be on the page script and not in the code-behind. If you want to use a
handler in the code-behind, remove OnClick attribute, go to design view and
double-click the button. The code-behind will open on the right function. Or
you can select event handler in the button properties panel on Events tab.
Or you can do it without design view whatsoever. Just go to the code-behind
and add a line for registering the event-handling method for the Click
event of the button:
btnSignIn.Click += new EventHandler(this.btnSignIn_Click);

When you do it in the design view, this line is added to the automatically
generated InitializeComponent() method.

Eliyahu

"Columbia Pike" <wh******@whatever.com> wrote in message
news:Xn**********************************@207.46.2 48.16...
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.

Nov 18 '05 #3
Eliyahu Goldin wrote:
If you use OnClick attribute in the page's HTML view, the name is
expected to be on the page script and not in the code-behind.

That's not actually true. I'm using

<% Page Inherits="myNamespace.myPage" %>

with a compiled codebehind page and I can assign event handlers with OnClick
just fine.

It seems like InitializeComponent is only there for the designer....

--
jo inferis
Nov 18 '05 #4
Thank you for the correction about inheritance, you are right.

InitializeComponent does have a use in run-time. When you add event handlers
via design view, VisualStudio creates private methods in the code-behind and
doesn't create OnClick attribute in the aspx. Then it is InitializeComponent
that actually establishes links between controls and their event handlers.

Eliyahu

"Jo Inferis" <in*****@NOSPAM.gotadsl.co.uk> wrote in message
news:es*************@TK2MSFTNGP10.phx.gbl...
Eliyahu Goldin wrote:
If you use OnClick attribute in the page's HTML view, the name is
expected to be on the page script and not in the code-behind. That's not actually true. I'm using

<% Page Inherits="myNamespace.myPage" %>

with a compiled codebehind page and I can assign event handlers with

OnClick just fine.

It seems like InitializeComponent is only there for the designer....

--
jo inferis

Nov 18 '05 #5
Hello everyone...after your tips I did some more trial and error and now
the code is working. I'm able to fetch the db list. All I did was replace

codebehind="Connect.aspx.cs"

with

Inherits="MyNS.Connect"

in the login.aspx page, after including the CodeBehind in a namespace MyNS.
I'd appreciate any explanation for this difference in behavior.

Thank you once again for all who responded.
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Liza | last post by:
dear all, does a client side script always need a server side script in order to function? how can i get my javascript application to send the details of a user filled form to me without...
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
6
by: Tim Cartwright | last post by:
I have a page that has the login control on it, nothing else. This page inherits from a master page, neither page has any code in it. This page works perfectly when running on the WebDev debug web...
2
by: keithb | last post by:
A web site published from its development environment (VS Web Server) to an IIS 6.0 site displays this message: Compiler Error Message: CS0030: Cannot convert type 'ASP.login_aspx' to...
130
by: Daniel Manes | last post by:
I'm baffled. I have a column in a SQL Server Express database called "Longitude," which is a float. When I view the table in a DataGridView, some of the numbers, which only have two decimal places...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
5
by: manjitsarma | last post by:
I have changed the following original vb.net window application code Public Overrides Function SetTheme(ByRef frmObj As System.Windows.Forms) As Boolean into c#.net as-
5
by: daveh551 | last post by:
What, from a high level point of view, is the difference (in Visual Studio 2005) between Website (accessed with Open Website or Create Website from the StartPage) that is an ASP.NET Website, and a...
33
by: rvj | last post by:
if you redirect on an IIS , must the client url address bar always be updated with the new address. what options are? Q1 if a user requests http://old.com , is there a method of ASP...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.