473,396 Members | 1,914 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,396 software developers and data experts.

usercontrols + code-behind

wh
After spent a good half day looking for a solution I'm no further finding an
answer so I'd appreciate any ideas as to how this can be done.

I have developed a user control that resides in a .ascx file with the
associated .ascx.cs file holding the code. Each .aspx page that uses this
control has appropriate <% Register %> directives at the top of the page:

<%@ Register tagprefix="mytag" tagname="mycontrol"
src="usercontrols/mycontrol.ascx" %>

The code-behind file (.aspx.cs) for each page has a reference to the class
(MyControl) that has been defined in the code-behind (.ascx.cs) file for the
control.

protected MyControl myCtl;

Currently, the project I'm working on is built using VS.NET and is thus
compiled as a single .DLL which sits in the BIN subdirectory. This works
FINE.

The problem comes when I remove the .DLL that VS.NET builds and instead use
a 'SRC' attribute in the <%@ PAGE %> directive for each page. This allows me
to make changes to the code sitting in the code-behind file while at the
same time ensuring that the .NET Framework compiles any modifications on the
fly. This has worked well in the past. However, since adding the control to
the project, I now get an error whenever the .NET Framework compiles each
..aspx page containing the definition for the control:

protected MyControl myCtl;

I can't remember the exact error, but it's complaing that the 'MyControl'
type is not recognised. I know for a fact that it's in the same namespace as
the class in the code behind file for the .aspx page. It seems that .NET is
compiling the .ASPX page before the .ASCX page, and as a consequence knows
nothing about the MyControl class.

I have tried using the <%@ Assembly %> and <%@ Reference %> directives in
the .aspx file without any success.

Thanks,
Wayne.
Nov 18 '05 #1
1 1076
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"wh" <wa***@nospam.pyesmeadow.com> wrote in message
news:lb*********************@newsfep2-win.server.ntli.net...
After spent a good half day looking for a solution I'm no further finding an answer so I'd appreciate any ideas as to how this can be done.

I have developed a user control that resides in a .ascx file with the
associated .ascx.cs file holding the code. Each .aspx page that uses this
control has appropriate <% Register %> directives at the top of the page:

<%@ Register tagprefix="mytag" tagname="mycontrol"
src="usercontrols/mycontrol.ascx" %>

The code-behind file (.aspx.cs) for each page has a reference to the class
(MyControl) that has been defined in the code-behind (.ascx.cs) file for the control.

protected MyControl myCtl;

Currently, the project I'm working on is built using VS.NET and is thus
compiled as a single .DLL which sits in the BIN subdirectory. This works
FINE.

The problem comes when I remove the .DLL that VS.NET builds and instead use a 'SRC' attribute in the <%@ PAGE %> directive for each page. This allows me to make changes to the code sitting in the code-behind file while at the
same time ensuring that the .NET Framework compiles any modifications on the fly. This has worked well in the past. However, since adding the control to the project, I now get an error whenever the .NET Framework compiles each
.aspx page containing the definition for the control:

protected MyControl myCtl;

I can't remember the exact error, but it's complaing that the 'MyControl'
type is not recognised. I know for a fact that it's in the same namespace as the class in the code behind file for the .aspx page. It seems that .NET is compiling the .ASPX page before the .ASCX page, and as a consequence knows
nothing about the MyControl class.

I have tried using the <%@ Assembly %> and <%@ Reference %> directives in
the .aspx file without any success.

Thanks,
Wayne.

Nov 18 '05 #2

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

Similar topics

1
by: Kate | last post by:
Hi: I have a picturebox control, and at runtime various usercontrols are added to it to make a diagram. As dynamically added usercontrols, they are of type VBExtender. Is there a way to save...
2
by: Emma | last post by:
Hi, I'm developing a GUI with almost all Usercontrols. It's been working wonderfull up till a few weeks ago, and really crashed yesterday. Suddenly I can no longer add some of my usercontrols...
4
by: Anders K. Jacobsen [DK] | last post by:
Hi I have some common UserControls i want to share between to sites (on the same mashine but on diffrent virtual paths). right now i have on solution file with aprox 10 projects. 2 of these is...
3
by: YYZ | last post by:
I swear I've done my research, and now I was just hoping someone could explain this to me. I've got a base class (usercontrol) that I am using just as an interface. Meaning, I've defined...
0
by: seigo | last post by:
Hello, I faced with the following problem. I have a PlaceHolder on a page and a few UserControls which have custom events, for instance: public delegate void SelectHandler(object sender,...
3
by: Nathan Sokalski | last post by:
I have my UserControls in a subdirectory called usercontrols. In the code for one of my UserControls I have the following: Public Property adimage() As String Get Return...
4
by: Nathan Sokalski | last post by:
In several of my UserControls I add properties. If I access these properties in the CodeBehind of the pages that use the controls, I recieve an error when compiling. The reason for this is because...
7
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
0
by: Screaming Eagles 101 | last post by:
Hi, since a while I have a problem with a solution containing 2 projects , let's say a project Main with the interface and a project controls with 4 usercontrols, which I use on the 'Main' form. ...
0
by: kea62227 | last post by:
I need to present some data. The obvious way is to use a datagridview, but I would like to make it presented better. Therefore I have created a usercontrol that presents a row of data more...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...
0
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...

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.