473,326 Members | 2,111 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,326 software developers and data experts.

Issue with asp code behind

Hi,

I have an ASP page with the page directive:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

It has some controls defined like:
<p<asp:Button ID="SearchButton" OnClick = "SearchButton_Click"
CssClass="button" Text="Search" runat="server" / </p>

The code behind has the control defined as:
protected TextBox SearchTextBox;

I am getting an error: "SearchtextBox already defined".

If I remove it, I get "SerachTextBox" no defined. Am I missing
something?

Thanks.

Nov 17 '06 #1
1 883
Hi,

avanti wrote:
Hi,

I have an ASP page with the page directive:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>

It has some controls defined like:
<p<asp:Button ID="SearchButton" OnClick = "SearchButton_Click"
CssClass="button" Text="Search" runat="server" / </p>

The code behind has the control defined as:
protected TextBox SearchTextBox;

I am getting an error: "SearchtextBox already defined".

If I remove it, I get "SerachTextBox" no defined. Am I missing
something?

Thanks.
In 2.0, you don't need to explicitly declare the controls in the code
behind anymore like in 1.1. The compiler should take care of that for
you, by creating a <pagename>.aspx.designer.cs file in which all the
controls should be declared. This is possible because 2.0 introduced
partial classes in C#, so one class can be defined in more than one file.

So normally, if you add one control in your ASPX page, compile, then the
control should be added to the designer.cs file. Check that it's the
case (you must see the designer.cs file in your Solution explorer, you
must open it, and check that the control is actually available).

If it is not available, then I would rename your ASPX file to something
else, add a new ASPX file with the old name, and then copy paste the
controls from the old one to the new one. Sometimes (especially when you
convert 1.1 apps to 2.0), the designer.cs file doesn't work well.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 17 '06 #2

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

Similar topics

2
by: brian | last post by:
I've created an asp.net application that uses vb.net code behind pages. This application runs fine on my local machine (I have IIS installed locally for testing). However, when I place the...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
3
by: Jeffery Franzen | last post by:
Anyone know where the documentation is regarding Activex controls in asp web forms? I'm using VS.NET 2002 enterprise and am trying to use Activex controls in vb.net web form app. I do the add...
12
by: jburkle | last post by:
Hello all, I am still having an issue where multiple Message Boxes are being displayed to the user from the same form at one time. This issue hides the boxes behind the forms since the forms take...
3
by: Purti Malhotra | last post by:
Hi All, In our Web hosting environment we are using Virtual hosting i.e. multiple websites are on one server and multiple domains are pointing to a single website. Issue: We have two domains...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
10
by: Stephany Young | last post by:
When one uses the System.Diagnostics.Process.Start method to launch a common or garden Console application, one can set the WindowStyle property of the StartInfo object to ProcessWindowStyle.Hidden...
2
by: pra__ | last post by:
Hi, i am designing a WYSIWYG editor. I want that when the user presses a 'TAB', a count of four spaces should be put. I used this code, <html> <head> <script> function chk(e){ if...
17
by: dijnr | last post by:
Issue NOT use This script makes the popup sit behind the main webpage once clicked off it and if another image is chosen to enlarge the image will not be seen as it is still sits behind the main...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.