473,748 Members | 8,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'ASP.login_aspx ' does not contain a definition for 'btnSignIn_Clic k' - 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_Clic k'

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.dl l).

Here's the command I used for making the dll -

C:\Inetpub\wwwr oot\xml\dotnet> csc /out:Connect.dll /r:System.dll,Sy stem.web.dll,Sy stem.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.Com mon;
using System.Data.Sql Client;
using System.Data.Sql Types;
/// <summary>
/// Description of Class1.
/// </summary>
public class Connect : System.Web.UI.P age
{
public System.Web.UI.W ebControls.Text Box txtLogin;
public System.Web.UI.W ebControls.Requ iredFieldValida tor RFVLogin;
public System.Web.UI.W ebControls.Text Box txtPassword;
public System.Web.UI.W ebControls.Requ iredFieldValida tor RFVPassword;
public System.Web.UI.W ebControls.Butt on btnSignIn;
public System.Web.UI.W ebControls.Labe l Msg;

protected void Page_Load(objec t 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.Te xt;
SqlConnection conn = new SqlConnection(" server=localhos t;uid=" + txtLogin.Text + ";pwd=" + txtPassword.Tex t);
try {
conn.Open();
SqlCommand strsql = new SqlCommand("SEL ECT name FROM master.dbo.sysd atabases WHERE has_dbaccess(na me) = 1 ORDER BY name ", conn);
SqlDataReader myreader;
myreader = strsql.ExecuteR eader();
}
catch(SqlExcept ion 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="Con nect.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:RequiredFi eldValidator id="RFVLogin" runat="server" ErrorMessage="* " Display="Static " ControlToValida te="UserName"> </asp:RequiredFie ldValidator>
</td>
</tr>
<tr>
<td>
Password:</td>
<td>
<asp:TextBox id="txtPassword " runat="server" TextMode="Passw ord"></asp:TextBox>
</td>
<td>
<asp:RequiredFi eldValidator id="RFVPassword " runat="server" ErrorMessage="* " Display="Static " ControlToValida te="UserPass"> </asp:RequiredFie ldValidator>
</td>
</tr>
</tbody>
</table>
<asp:Button id="btnSignIn" onclick="btnSig nIn_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 8727
You have to rebuild the cs file and copy the builded .dll file in the bin
sub folder again

Regards
Martin

"Columbia Pike" <wh******@whate ver.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.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_Clic k'

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.dl l).
Here's the command I used for making the dll -

C:\Inetpub\wwwr oot\xml\dotnet> csc /out:Connect.dll /r:System.dll,Sy stem.web.dll,Sy stem.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.Com mon;
using System.Data.Sql Client;
using System.Data.Sql Types;
/// <summary>
/// Description of Class1.
/// </summary>
public class Connect : System.Web.UI.P age
{
public System.Web.UI.W ebControls.Text Box txtLogin;
public System.Web.UI.W ebControls.Requ iredFieldValida tor RFVLogin;
public System.Web.UI.W ebControls.Text Box txtPassword;
public System.Web.UI.W ebControls.Requ iredFieldValida tor RFVPassword;
public System.Web.UI.W ebControls.Butt on btnSignIn;
public System.Web.UI.W ebControls.Labe l Msg;

protected void Page_Load(objec t 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.Te xt;
SqlConnection conn = new SqlConnection(" server=localhos t;uid=" + txtLogin.Text + ";pwd=" + txtPassword.Tex t); try {
conn.Open();
SqlCommand strsql = new SqlCommand("SEL ECT name FROM master.dbo.sysd atabases WHERE has_dbaccess(na me) = 1 ORDER BY name ", conn); SqlDataReader myreader;
myreader = strsql.ExecuteR eader();
}
catch(SqlExcept ion 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="Con nect.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:RequiredFi eldValidator id="RFVLogin" runat="server" ErrorMessage="* " Display="Static "
ControlToValida te="UserName"> </asp:RequiredFie ldValidator> </td>
</tr>
<tr>
<td>
Password:</td>
<td>
<asp:TextBox id="txtPassword " runat="server" TextMode="Passw ord"></asp:TextBox> </td>
<td>
<asp:RequiredFi eldValidator id="RFVPassword " runat="server" ErrorMessage="* " Display="Static "
ControlToValida te="UserPass"> </asp:RequiredFie ldValidator> </td>
</tr>
</tbody>
</table>
<asp:Button id="btnSignIn" onclick="btnSig nIn_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(th is.btnSignIn_Cl ick);

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

Eliyahu

"Columbia Pike" <wh******@whate ver.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.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_Clic k'

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.dl l).
Here's the command I used for making the dll -

C:\Inetpub\wwwr oot\xml\dotnet> csc /out:Connect.dll /r:System.dll,Sy stem.web.dll,Sy stem.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.Com mon;
using System.Data.Sql Client;
using System.Data.Sql Types;
/// <summary>
/// Description of Class1.
/// </summary>
public class Connect : System.Web.UI.P age
{
public System.Web.UI.W ebControls.Text Box txtLogin;
public System.Web.UI.W ebControls.Requ iredFieldValida tor RFVLogin;
public System.Web.UI.W ebControls.Text Box txtPassword;
public System.Web.UI.W ebControls.Requ iredFieldValida tor RFVPassword;
public System.Web.UI.W ebControls.Butt on btnSignIn;
public System.Web.UI.W ebControls.Labe l Msg;

protected void Page_Load(objec t 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.Te xt;
SqlConnection conn = new SqlConnection(" server=localhos t;uid=" + txtLogin.Text + ";pwd=" + txtPassword.Tex t); try {
conn.Open();
SqlCommand strsql = new SqlCommand("SEL ECT name FROM master.dbo.sysd atabases WHERE has_dbaccess(na me) = 1 ORDER BY name ", conn); SqlDataReader myreader;
myreader = strsql.ExecuteR eader();
}
catch(SqlExcept ion 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="Con nect.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:RequiredFi eldValidator id="RFVLogin" runat="server" ErrorMessage="* " Display="Static "
ControlToValida te="UserName"> </asp:RequiredFie ldValidator> </td>
</tr>
<tr>
<td>
Password:</td>
<td>
<asp:TextBox id="txtPassword " runat="server" TextMode="Passw ord"></asp:TextBox> </td>
<td>
<asp:RequiredFi eldValidator id="RFVPassword " runat="server" ErrorMessage="* " Display="Static "
ControlToValida te="UserPass"> </asp:RequiredFie ldValidator> </td>
</tr>
</tbody>
</table>
<asp:Button id="btnSignIn" onclick="btnSig nIn_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="myNam espace.myPage" %>

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

It seems like InitializeCompo nent is only there for the designer....

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

InitializeCompo nent 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 InitializeCompo nent
that actually establishes links between controls and their event handlers.

Eliyahu

"Jo Inferis" <in*****@NOSPAM .gotadsl.co.uk> wrote in message
news:es******** *****@TK2MSFTNG P10.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="myNam espace.myPage" %>

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

OnClick just fine.

It seems like InitializeCompo nent is only there for the designer....

--
jo inferis

Nov 18 '05 #5
Hello everyone...afte r 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="Con nect.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
1334
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 having to have a server side script? if i have both server side and client side script in a web application, will the resulting application run as a client or server?
2
2842
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 to it to view additional details about the selected result (a second database query is triggered). I want this second query to pop up in a new window, the way it would if I used "window.open" in javascript. I've added a function in the
6
14565
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 server. I am able to log in. However after publishing the page to my local IIS, it results in the below error. This error is occurring on the Visual Studio.Net 2k5 release version, but did not occur on the beta 2, same code. A point of interest, is...
2
5015
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 'System.Web.UI.WebControls.Login' Anyone have an idea about the cause? Thanks,
130
6599
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 in the database show up with *15* decimal places and are ever so slightly off (in the example in the subject line, by about 2E-15). I'm not doing any operations on this column. It's just running a stored procedure which performs a pretty basic...
0
3668
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 delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. · When was the first version of .NET released? The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on...
5
1938
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
3008
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 Project that is created with the "ASP.NET Application" template? I see some obvious differences: the Project creates the working folder under the Visual Studio 2005\Projects directory, while the Website creates it in the Inetpub\wwwroot...
33
2667
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 redirection to http://new.com which does not update the client browser's address bar Q2 ... or is this one of the main benefits of the IIS URL rewriter ??
0
8984
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9312
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8237
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3300
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.