J
Jon Ratcliffe
I am not using (can't use) vs.net to create my asp.net pages - I am
using dreamweaver MX (essentially using it as a glorified notepad).
I am using C#.
Pages involved:
header.ascx - an in page (ie not a code behind) user control
default.aspx - an asp.net page
default.aspx.cs - a code behind page for the aspx page
I am loading the user control dynamically into the code behind file
(default.aspx.cs) as follows:
---
control = LoadControl("../_includes/header.ascx");
phPageHeader.Controls.Add(control);
---
phPageHeader is a simple asp
laceHolder, this all works fine and my
control is rendered to the page as expected.
I then try to set a property inside the User Control, first casting
the control object to its correct type...
---
PageHeader header = (PageHeader)control;
header.strCrumbtrail = "Hello World!";
---
Running the code then produces an error (CS0246: The type or namespace
name 'PageHeader' could not be found (are you missing a using
directive or an assembly reference?))
Now, I kind of know why this is happening. My Code Behind page has no
knowledge of what a PageHeader is - it knows of no such class type.
In any other instance this would be a simple case of putting a "using"
statement at the top of my code behind page. In this case I cannot do
that because my User Control is not compiled into any namespace (its
compiled at runtime in the same way as my aspx pages).
What do I do to get my code behind page to recognise my User Control
after I've loaded it?
Does it involve compiling the control (using command line tools) every
time I modify it? Something that seems crazy for what could be done in
seconds whith include files in trad ASP!
Or is there a way of dynamically using this class type in my code
behind page.
After hours of searching, I've seen quite a few postings along these
lines but absolutely no solutions!
Any help would be greatly appreciated.
Jon R
using dreamweaver MX (essentially using it as a glorified notepad).
I am using C#.
Pages involved:
header.ascx - an in page (ie not a code behind) user control
default.aspx - an asp.net page
default.aspx.cs - a code behind page for the aspx page
I am loading the user control dynamically into the code behind file
(default.aspx.cs) as follows:
---
control = LoadControl("../_includes/header.ascx");
phPageHeader.Controls.Add(control);
---
phPageHeader is a simple asp
control is rendered to the page as expected.
I then try to set a property inside the User Control, first casting
the control object to its correct type...
---
PageHeader header = (PageHeader)control;
header.strCrumbtrail = "Hello World!";
---
Running the code then produces an error (CS0246: The type or namespace
name 'PageHeader' could not be found (are you missing a using
directive or an assembly reference?))
Now, I kind of know why this is happening. My Code Behind page has no
knowledge of what a PageHeader is - it knows of no such class type.
In any other instance this would be a simple case of putting a "using"
statement at the top of my code behind page. In this case I cannot do
that because my User Control is not compiled into any namespace (its
compiled at runtime in the same way as my aspx pages).
What do I do to get my code behind page to recognise my User Control
after I've loaded it?
Does it involve compiling the control (using command line tools) every
time I modify it? Something that seems crazy for what could be done in
seconds whith include files in trad ASP!
Or is there a way of dynamically using this class type in my code
behind page.
After hours of searching, I've seen quite a few postings along these
lines but absolutely no solutions!
Any help would be greatly appreciated.
Jon R