Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > NullReferenceException With Different Register Directive

Reply
Thread Tools

NullReferenceException With Different Register Directive

 
 
Marvin Massih
Guest
Posts: n/a
 
      03-23-2006
Hello,

I have written a user control using .NET 1.1 and have had some trouble.
But to make sure it's not a problem with my code I have had the designer
(VS.NET 2003) create a new user control for me and include that in a new
web form.

The user control only contains a Repeater:

------ SNIP ------
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<asp:Label Runat="server">
<%# Container.DataItem.ToString() %>
</asp:Label>
</ItemTemplate>
</asp:Repeater>
------ SNAP ------

It is supposed to be filled in the code-behind like this:

------ SNIP ------
protected Repeater Repeater1;

private void Page_Load(object sender, EventArgs e)
{
ArrayList a = new ArrayList();
a.Add("Hello");
a.Add("World");

Repeater1.DataSource = a;
Repeater1.DataBind();
}
------ SNAP ------

I then dragged this user control onto a new web form and everything
works as a charm.

Obviously this is because the designer creates a Register directive like
this:

------ SNIP ------
<%@ Register TagPrefix="uc1" TagName="Foobar" Src="Foobar.ascx" %>
------ SNAP ------

If I change this to

------ SNIP ------
<%@ Register Tagprefix="XY" Namespace="My.Namespace" Assembly="XYWeb" %>
------ SNAP ------

The control is still loaded, but Repeater1 is null in Page_Load, which
causes a NullReferenceException to be thrown.

Any help will be highly appreciated.

-Marvin

--
http://groenndemon.de/blog
 
Reply With Quote
 
 
 
 
Ward Bekker
Guest
Posts: n/a
 
      03-23-2006
Hi Marvin,

Did you try to add the control from the XYWeb to the toolbox and drag it
to the page? Maybe a different register tag is added that might work better.

--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
 
Reply With Quote
 
 
 
 
Marvin Massih
Guest
Posts: n/a
 
      03-23-2006
Hi Ward,

Ward Bekker wrote:
> Did you try to add the control from the XYWeb to the toolbox and drag it
> to the page? Maybe a different register tag is added that might work
> better.


Tried now, VS.NET says "XYWeb does not contain any elements that can be
placed in the toolbox" or something like that (I have the German version).

But the Foobar control is compiled into the assembly, at least it's part
of the project.

-Marvin

--
http://groenndemon.de/blog
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Null Reference Exception on @Register Directive =?Utf-8?B?UGF1bCBQcmV3ZXR0?= ASP .Net 0 09-27-2006 02:02 PM
NullReferenceException With Different Register Directive Marvin Massih ASP .Net Building Controls 0 03-23-2006 10:23 AM
Problem with runtime compilation of aspx files. Register Directive ignores Assembly Dan ASP .Net 3 06-14-2004 06:13 AM
The Register directive for the referenced assembly Sergey Polyakov ASP .Net 0 05-24-2004 05:38 PM
The 'Location' attribute is not supported by the 'OutPutCache' directive????when i set in the directive .NET Follower ASP .Net 1 02-13-2004 10:32 AM



Advertisments