473,508 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cannot use codebehind for user control!

Getting really frustrated, I've been trying for 6 hours now! Got this very
simple web app having a main .aspx page which has a user control (added with
the Register directive) and the TemplateTop.ascx wich works 100% until I try
adding codebehind, eg;

<%@ Control Codebehind="TemplateTop.ascx.cs" Inherits="TemplateTop" %>

And in the TemplateTop.ascx.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(object sender, System.EventArgs e)
{
MyLiteral1.Text = "success!";
}
}
The error is:
Parser Error Message: Could not load type 'TemplateTopCB'.
Nov 18 '05 #1
5 3201
Is it that your class name (w/CB) does not match "inherits="?

"news.microsoft.com" wrote:
Getting really frustrated, I've been trying for 6 hours now! Got this very
simple web app having a main .aspx page which has a user control (added with
the Register directive) and the TemplateTop.ascx wich works 100% until I try
adding codebehind, eg;

<%@ Control Codebehind="TemplateTop.ascx.cs" Inherits="TemplateTop" %>

And in the TemplateTop.ascx.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(object sender, System.EventArgs e)
{
MyLiteral1.Text = "success!";
}
}
The error is:
Parser Error Message: Could not load type 'TemplateTopCB'.

Nov 18 '05 #2
sorry my mistake, it is Inherits="TemplateTopCB" in the code - so this is
not the cause of the error!

"Bill Borg" <Bi******@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
Is it that your class name (w/CB) does not match "inherits="?

"news.microsoft.com" wrote:
Getting really frustrated, I've been trying for 6 hours now! Got this
very
simple web app having a main .aspx page which has a user control (added
with
the Register directive) and the TemplateTop.ascx wich works 100% until I
try
adding codebehind, eg;

<%@ Control Codebehind="TemplateTop.ascx.cs" Inherits="TemplateTop" %>

And in the TemplateTop.ascx.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(object sender, System.EventArgs e)
{
MyLiteral1.Text = "success!";
}
}
The error is:
Parser Error Message: Could not load type 'TemplateTopCB'.

Nov 18 '05 #3
thought I'd let you know it's 100% working after I added
Src="TemplateTop.ascx.cs"

to the @Control directive

This puzzles me though. It tells me that the Codebehind code has to be
precompiled by Visual Web Developer to work. What if I was for instance
using a text editor to do this web, would it then be impossible without
precompiling the .cs code in command-line?!
"news.microsoft.com" <db****@simnet.is> wrote in message
news:OK**************@TK2MSFTNGP15.phx.gbl...
sorry my mistake, it is Inherits="TemplateTopCB" in the code - so this is
not the cause of the error!

"Bill Borg" <Bi******@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
Is it that your class name (w/CB) does not match "inherits="?

"news.microsoft.com" wrote:
Getting really frustrated, I've been trying for 6 hours now! Got this
very
simple web app having a main .aspx page which has a user control (added
with
the Register directive) and the TemplateTop.ascx wich works 100% until I
try
adding codebehind, eg;

<%@ Control Codebehind="TemplateTop.ascx.cs" Inherits="TemplateTop" %>

And in the TemplateTop.ascx.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(object sender, System.EventArgs e)
{
MyLiteral1.Text = "success!";
}
}
The error is:
Parser Error Message: Could not load type 'TemplateTopCB'.


Nov 18 '05 #4
what on earth is going on?! It works for a few times and then suddenly
(without having changed anything!!) - it is if like .Net just loves creating
errors for me!!!

The system cannot find the file specified.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: The system cannot find
the file specified.
Assembly Load Trace: The following information can be helpful to determine
why the assembly 'lslh5c-x, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' could not be loaded.
Nov 18 '05 #5
I usually don't use the register directive directly. I'd remove it and drag
the control onto your form via the IDE, which does that for you. I presume
this is the same for C# as it is VB. Have fun.

"news.microsoft.com" wrote:
sorry my mistake, it is Inherits="TemplateTopCB" in the code - so this is
not the cause of the error!

"Bill Borg" <Bi******@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
Is it that your class name (w/CB) does not match "inherits="?

"news.microsoft.com" wrote:
Getting really frustrated, I've been trying for 6 hours now! Got this
very
simple web app having a main .aspx page which has a user control (added
with
the Register directive) and the TemplateTop.ascx wich works 100% until I
try
adding codebehind, eg;

<%@ Control Codebehind="TemplateTop.ascx.cs" Inherits="TemplateTop" %>

And in the TemplateTop.ascx.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(object sender, System.EventArgs e)
{
MyLiteral1.Text = "success!";
}
}
The error is:
Parser Error Message: Could not load type 'TemplateTopCB'.


Nov 18 '05 #6

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

Similar topics

0
622
by: Colin | last post by:
Hi there, I really need your help on this. I'm trying to learn to using the VS.2003 to create a User Control. In my aspx code has no problem to use the property "grossWaye" that has "register" in...
1
1161
by: needin4mation | last post by:
Hi, I am using C# in asp.net. I have my treeview control from my built ..dll on my toolbox. I can drop it on the webpage. What I cannot do is reference treeview objects from the codebehind form....
2
13719
by: adiel | last post by:
Hello, I am trying to access the properties and methods from a user control within the code-behind file for a webform but I am receiving the message: Name 'MenuBar1' is not declared It does...
2
2872
by: Graham Allwood | last post by:
I'm reading the Essential ASP.NET book by Fritz onion and he says that when VS.NET creates a new .aspx page for you is uses the codebehind attribute on the Page directive rather than the src...
6
1775
by: Nehal Shah | last post by:
I've read that in the Page Directive of an aspx page, changing the CodeBehind attribute to Src saves you from having to compile the page before refreshing. This is preferable in a large...
0
2028
by: M K | last post by:
Okay, here is my message: The base class includes the field 'Preview1', but its type (ICUser.uCtrlPreview) is not compatible with the type of control (ASP.previewImg_ascx). What I am trying to...
3
5364
by: Dave | last post by:
Greetings, I have a user control in my web form. I cannot reference it in code. My HTML File has the header: <%@ Register TagPrefix="PLB" Tagname="PIPSidebar" src="ProjectListSidebar.ascx"...
11
1290
by: Greg Smalter | last post by:
I'm converting some ASP web projects from VS 2003 to VS2005/ASP 2.0. The worst problem I've run into is all references (in codebehind CS files) to UserControls fail. I get the error "The type...
10
2397
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's...
0
7231
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,...
0
7132
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
7336
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
7401
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...
1
7063
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
7504
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
5640
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,...
1
5059
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...
0
4720
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...

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.