473,586 Members | 2,707 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.asc x wich works 100% until I try
adding codebehind, eg;

<%@ Control Codebehind="Tem plateTop.ascx.c s" Inherits="Templ ateTop" %>

And in the TemplateTop.asc x.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(objec t sender, System.EventArg s e)
{
MyLiteral1.Text = "success!";
}
}
The error is:
Parser Error Message: Could not load type 'TemplateTopCB' .
Nov 18 '05 #1
5 3207
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.asc x wich works 100% until I try
adding codebehind, eg;

<%@ Control Codebehind="Tem plateTop.ascx.c s" Inherits="Templ ateTop" %>

And in the TemplateTop.asc x.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(objec t sender, System.EventArg s 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="Templ ateTopCB" in the code - so this is
not the cause of the error!

"Bill Borg" <Bi******@discu ssions.microsof t.com> wrote in message
news:10******** *************** ***********@mic rosoft.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.asc x wich works 100% until I
try
adding codebehind, eg;

<%@ Control Codebehind="Tem plateTop.ascx.c s" Inherits="Templ ateTop" %>

And in the TemplateTop.asc x.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(objec t sender, System.EventArg s 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="TemplateTo p.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******** ******@TK2MSFTN GP15.phx.gbl...
sorry my mistake, it is Inherits="Templ ateTopCB" in the code - so this is
not the cause of the error!

"Bill Borg" <Bi******@discu ssions.microsof t.com> wrote in message
news:10******** *************** ***********@mic rosoft.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.asc x wich works 100% until I
try
adding codebehind, eg;

<%@ Control Codebehind="Tem plateTop.ascx.c s" Inherits="Templ ateTop" %>

And in the TemplateTop.asc x.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(objec t sender, System.EventArg s 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.FileN otFoundExceptio n: 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="Templ ateTopCB" in the code - so this is
not the cause of the error!

"Bill Borg" <Bi******@discu ssions.microsof t.com> wrote in message
news:10******** *************** ***********@mic rosoft.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.asc x wich works 100% until I
try
adding codebehind, eg;

<%@ Control Codebehind="Tem plateTop.ascx.c s" Inherits="Templ ateTop" %>

And in the TemplateTop.asc x.cs file:

using ...
public class TemplateTopCB : UserControl
{
public Literal MyLiteral1;
void Page_Load(objec t sender, System.EventArg s 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 the aspx code if I don't use "Codebehind" directive. If I try to move the <script></script> coding the Codebehind of the VS2003. I don't know how to...
1
1169
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. I can see: protected Microsoft.Web.UI.WebControls.TreeView TreeView1; But as soon as I try something like:
2
13724
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 not recognize the user control in the code behind... Here is the code for the user control: MenuBar.ascx:
2
2877
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 attribute. From what I understand the src attrib is standard ASP.NET but the codebehind attribute is only understood by VS.NET. Doesn't this make the...
6
1779
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 development environment where rather than having each developer running a local copy of a website, they can make changes simultaneously to a central web...
0
2034
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 do is use a user control I created in a page. This control is a composite of an image and a couple of labels. I wanted include properties through...
3
5370
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" %> and references the User Control... <PLB:PIPSIDEBAR id="PIPSIDEBAR1" runat="server"></PLB:PIPSIDEBAR>
11
1299
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 or namespace 'MyUserControl' does not exist in the namespace 'The.Correct.Namespace' (are you missing an assembly reference?)" even though the user...
10
2409
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 my question. Once the UserControl is dropped onto the container page, how can I perform some action on the codebehind of the container page from...
0
8202
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. ...
1
7959
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...
0
8216
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
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...
1
5710
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...
0
5390
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...
0
3837
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...
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
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...

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.