B
Brian Vallelunga
This is very strange. I have a server control that I built called "Test". It
is in the namespace "Vallelunga.Guestbook". The code for the usercontrol
looks like this:
namespace Vallelunga.Guestbook
{
public class Test : System.Web.UI.Control
{
public Test()
{
this.Context.Trace.Write("Test constructor");
}
protected override void Render(HtmlTextWriter output)
{
output.Write("Hello World");
}
}
}
This is compiled into a dll called Vallelunga.Guestbook.dll
That's about as simple as I can get. When I put a reference to it on a page,
I use:
<%@ Register Namespace="Vallelunga.Guestbook" tagprefix="guestbk"
Assembly="Vallelunga.Guestbook" %>
on the page...
<form runat="server">
<h1>Test</h1>
<guestbk:Test runat="server" id="test1" />
</form>
Does anyone see anything wrong with this? I've made much more complicated
controls before, so I think there must be some stupid error somewhere.
Anyway, when I run the page, I get an error highlighting the line:
this.Context.Trace.Write("Test constructor");
The error is "Object reference not set to an instance of an object"
if I comment out that line, the page loads, but no "Hello World" is ever
found. Nor does the control show in the control tree. It is like my
HtmlTextWriter doesn't have a context to write to or something. Any ideas?
Thanks,
Brian
is in the namespace "Vallelunga.Guestbook". The code for the usercontrol
looks like this:
namespace Vallelunga.Guestbook
{
public class Test : System.Web.UI.Control
{
public Test()
{
this.Context.Trace.Write("Test constructor");
}
protected override void Render(HtmlTextWriter output)
{
output.Write("Hello World");
}
}
}
This is compiled into a dll called Vallelunga.Guestbook.dll
That's about as simple as I can get. When I put a reference to it on a page,
I use:
<%@ Register Namespace="Vallelunga.Guestbook" tagprefix="guestbk"
Assembly="Vallelunga.Guestbook" %>
on the page...
<form runat="server">
<h1>Test</h1>
<guestbk:Test runat="server" id="test1" />
</form>
Does anyone see anything wrong with this? I've made much more complicated
controls before, so I think there must be some stupid error somewhere.
Anyway, when I run the page, I get an error highlighting the line:
this.Context.Trace.Write("Test constructor");
The error is "Object reference not set to an instance of an object"
if I comment out that line, the page loads, but no "Hello World" is ever
found. Nor does the control show in the control tree. It is like my
HtmlTextWriter doesn't have a context to write to or something. Any ideas?
Thanks,
Brian