By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,727 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,727 IT Pros & Developers. It's quick & easy.

Can't add to placeholder

P: n/a
Hi,

using vb.net 1.1

I am trying to add a control to a placeholder but am having problems with it.

I do it practically the same way as i do in C# (I have more C# skill than
VB.NET)and I have asked someone with more VB experience to look at it and
they can't see why it fails.

Any help appreciated...

Dim DocRSSLiteral As New Literal
DocRSSLiteral.Text = "<link href=""" & po.DisplayPath & """
rel=""alternate"" type=""application/rss+xml"" title=""" & po.DisplayName &
""" />"

RSSPlaceHolder.Controls.Add(DocRSSLiteral)

It is failing on the PlaceHolder Controls.Add line.

I can remove all these lines, try and add a label or a hyperlink and they
fail in exactly the same way.

Thanks for your help.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
Nov 15 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Sorry, forgot to say what the error was...

Object reference not set to an instance of an object

The placeholder is on the page and has been inserted into the Web Form
Designer Generated Code region.

As you can see, the object I am trying to add to the control is also declared.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"David Colliver" wrote:
Hi,

using vb.net 1.1

I am trying to add a control to a placeholder but am having problems with it.

I do it practically the same way as i do in C# (I have more C# skill than
VB.NET)and I have asked someone with more VB experience to look at it and
they can't see why it fails.

Any help appreciated...

Dim DocRSSLiteral As New Literal
DocRSSLiteral.Text = "<link href=""" & po.DisplayPath & """
rel=""alternate"" type=""application/rss+xml"" title=""" & po.DisplayName &
""" />"

RSSPlaceHolder.Controls.Add(DocRSSLiteral)

It is failing on the PlaceHolder Controls.Add line.

I can remove all these lines, try and add a label or a hyperlink and they
fail in exactly the same way.

Thanks for your help.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
Nov 15 '06 #2

P: n/a
Your code works fine here, are you sure that it is not po that is nothing?
Is po being properly declared?

Have you tried replacing DocRSSLiteral.Text = "...." with DocRSSLiteral.Text
= "TEST" to see if that works?

Other than that I have no idea.

"David Colliver" <Da***********@discussions.microsoft.comwrote in message
news:5E**********************************@microsof t.com...
Sorry, forgot to say what the error was...

Object reference not set to an instance of an object

The placeholder is on the page and has been inserted into the Web Form
Designer Generated Code region.

As you can see, the object I am trying to add to the control is also
declared.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"David Colliver" wrote:
>Hi,

using vb.net 1.1

I am trying to add a control to a placeholder but am having problems with
it.

I do it practically the same way as i do in C# (I have more C# skill than
VB.NET)and I have asked someone with more VB experience to look at it and
they can't see why it fails.

Any help appreciated...

Dim DocRSSLiteral As New Literal
DocRSSLiteral.Text = "<link href=""" & po.DisplayPath & """
rel=""alternate"" type=""application/rss+xml"" title=""" & po.DisplayName
&
""" />"

RSSPlaceHolder.Controls.Add(DocRSSLiteral)

It is failing on the PlaceHolder Controls.Add line.

I can remove all these lines, try and add a label or a hyperlink and they
fail in exactly the same way.

Thanks for your help.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

Nov 15 '06 #3

P: n/a
Apparently the RSSPlaceHolder is null.
This can happen if the Control *is* declared in codebehind (as
"protected", in C# terms), but there is no
<asp:PlaceHolder ID="RSSPlaceHolder" runat="server" />
in the aspx/ascx code. The ID value *must* match the name of the
control in codebehind and you *need* the runat=server attribute.

Another way this can happen: the codebehind is derived from some
specific baseclass where you declare that placeholder and work with it.
If you switch to design view, that declaration is added to the derived
codebehind class (the compiler will issue warnings about this
declaration hiding declarations from the baseclass)

Hans Kesting

Sorry, forgot to say what the error was...

Object reference not set to an instance of an object

The placeholder is on the page and has been inserted into the Web Form
Designer Generated Code region.

As you can see, the object I am trying to add to the control is also
declared.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

"David Colliver" wrote:
>Hi,

using vb.net 1.1

I am trying to add a control to a placeholder but am having problems with
it.

I do it practically the same way as i do in C# (I have more C# skill than
VB.NET)and I have asked someone with more VB experience to look at it and
they can't see why it fails.

Any help appreciated...

Dim DocRSSLiteral As New Literal
DocRSSLiteral.Text = "<link href=""" & po.DisplayPath & """
rel=""alternate"" type=""application/rss+xml"" title=""" & po.DisplayName &
""" />"

RSSPlaceHolder.Controls.Add(DocRSSLiteral)

It is failing on the PlaceHolder Controls.Add line.

I can remove all these lines, try and add a label or a hyperlink and they
fail in exactly the same way.

Thanks for your help.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

Nov 15 '06 #4

P: n/a
Hi,

The placeholder is declared in my aspx. The declaration is below...
<asp:PlaceHolder id=RSSPlaceHolder runat="server"></asp:PlaceHolder>

This automatically added...
Protected WithEvents RSSPlaceHolder As System.Web.UI.WebControls.PlaceHolder

to the codebehind. The codebehind is not being derived from any base class,
just System.Web.UI.Page.

To the other poster... Joseph, po is set else the code will fail where po is
used.
I actually remarked the line that uses po out and used a label which doesn't
have any variables, just text, tried to add the label and go the same prob
with that...

With what you are saying, the code should work, but it isn't working for me.
:-(

Regards,
Dave Colliver.
http://www.ManchesterFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"Hans Kesting" wrote:
Apparently the RSSPlaceHolder is null.
This can happen if the Control *is* declared in codebehind (as
"protected", in C# terms), but there is no
<asp:PlaceHolder ID="RSSPlaceHolder" runat="server" />
in the aspx/ascx code. The ID value *must* match the name of the
control in codebehind and you *need* the runat=server attribute.

Another way this can happen: the codebehind is derived from some
specific baseclass where you declare that placeholder and work with it.
If you switch to design view, that declaration is added to the derived
codebehind class (the compiler will issue warnings about this
declaration hiding declarations from the baseclass)

Hans Kesting

Sorry, forgot to say what the error was...

Object reference not set to an instance of an object

The placeholder is on the page and has been inserted into the Web Form
Designer Generated Code region.

As you can see, the object I am trying to add to the control is also
declared.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

"David Colliver" wrote:
Hi,

using vb.net 1.1

I am trying to add a control to a placeholder but am having problems with
it.

I do it practically the same way as i do in C# (I have more C# skill than
VB.NET)and I have asked someone with more VB experience to look at it and
they can't see why it fails.

Any help appreciated...

Dim DocRSSLiteral As New Literal
DocRSSLiteral.Text = "<link href=""" & po.DisplayPath & """
rel=""alternate"" type=""application/rss+xml"" title=""" & po.DisplayName &
""" />"

RSSPlaceHolder.Controls.Add(DocRSSLiteral)

It is failing on the PlaceHolder Controls.Add line.

I can remove all these lines, try and add a label or a hyperlink and they
fail in exactly the same way.

Thanks for your help.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available


Nov 15 '06 #5

P: n/a
This is getting weirder...

I have placed a label direct into the aspx and changed its text property to
display "Dave". I have run the page and no label.

I rebuilt the project and still no "Dave".

The label has appeared in the code behind. In the page load, I am
response.writing the label.text. When I do this, I get "Object reference not
set to an instance of an object".

I am using Microsoft CMS. It appears that the page has no reference to the
code behind or somehow the page has become disconnected, or the page itself
is cached as an object and that the codebehind just doesn't know what to do,
even though adding objects to the aspx drops the associated line in the
codebehind.

I have inherited this project, so am a little unsure of exactly what is
happening. I would appreciate some communication guiding me what to look for.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"David Colliver" wrote:
Hi,

The placeholder is declared in my aspx. The declaration is below...
<asp:PlaceHolder id=RSSPlaceHolder runat="server"></asp:PlaceHolder>

This automatically added...
Protected WithEvents RSSPlaceHolder As System.Web.UI.WebControls.PlaceHolder

to the codebehind. The codebehind is not being derived from any base class,
just System.Web.UI.Page.

To the other poster... Joseph, po is set else the code will fail where po is
used.
I actually remarked the line that uses po out and used a label which doesn't
have any variables, just text, tried to add the label and go the same prob
with that...

With what you are saying, the code should work, but it isn't working for me.
:-(

Regards,
Dave Colliver.
http://www.ManchesterFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"Hans Kesting" wrote:
Apparently the RSSPlaceHolder is null.
This can happen if the Control *is* declared in codebehind (as
"protected", in C# terms), but there is no
<asp:PlaceHolder ID="RSSPlaceHolder" runat="server" />
in the aspx/ascx code. The ID value *must* match the name of the
control in codebehind and you *need* the runat=server attribute.

Another way this can happen: the codebehind is derived from some
specific baseclass where you declare that placeholder and work with it.
If you switch to design view, that declaration is added to the derived
codebehind class (the compiler will issue warnings about this
declaration hiding declarations from the baseclass)

Hans Kesting

Sorry, forgot to say what the error was...
>
Object reference not set to an instance of an object
>
The placeholder is on the page and has been inserted into the Web Form
Designer Generated Code region.
>
As you can see, the object I am trying to add to the control is also
declared.
>
Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
>
"David Colliver" wrote:
>
>Hi,
>>
>using vb.net 1.1
>>
>I am trying to add a control to a placeholder but am having problems with
>it.
>>
>I do it practically the same way as i do in C# (I have more C# skill than
>VB.NET)and I have asked someone with more VB experience to look at it and
>they can't see why it fails.
>>
>Any help appreciated...
>>
>Dim DocRSSLiteral As New Literal
>DocRSSLiteral.Text = "<link href=""" & po.DisplayPath & """
>rel=""alternate"" type=""application/rss+xml"" title=""" & po.DisplayName &
>""" />"
>>
>RSSPlaceHolder.Controls.Add(DocRSSLiteral)
>>
>It is failing on the PlaceHolder Controls.Add line.
>>
>I can remove all these lines, try and add a label or a hyperlink and they
>fail in exactly the same way.
>>
>Thanks for your help.
>>
>Regards,
>Dave Colliver.
>http://www.AshfieldFOCUS.com
>~~
>http://www.FOCUSPortals.com - Portal franchises available
Nov 15 '06 #6

P: n/a
Found it.

This is a project I have inherited. It uses Microsoft CMS, which has a
template system.

The template system can reference ANY aspx page, and of course, ASPX has a
codebehind, but the codebehind gets compiled into a DLL, which means that
theoretically, you can have just one code behind service many aspx pages if
the pages are very similar.

So, that is what had happened. One code behind was servicing many pages. In
visual studio, you can't normally have seperate pages/codebehinds. However,
the aspx had been "Exclude from project", meaning it didn't need the
codebehind, but the page when requested will still call the DLL, and of
course, when searching the solution for the page, as it is not part of the
project, it will not be found.

Just thought I would post this for completion.

Regards,
Dave Colliver.
http://www.LeedsFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

"David Colliver" wrote:
This is getting weirder...

I have placed a label direct into the aspx and changed its text property to
display "Dave". I have run the page and no label.

I rebuilt the project and still no "Dave".

The label has appeared in the code behind. In the page load, I am
response.writing the label.text. When I do this, I get "Object reference not
set to an instance of an object".

I am using Microsoft CMS. It appears that the page has no reference to the
code behind or somehow the page has become disconnected, or the page itself
is cached as an object and that the codebehind just doesn't know what to do,
even though adding objects to the aspx drops the associated line in the
codebehind.

I have inherited this project, so am a little unsure of exactly what is
happening. I would appreciate some communication guiding me what to look for.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"David Colliver" wrote:
Hi,

The placeholder is declared in my aspx. The declaration is below...
<asp:PlaceHolder id=RSSPlaceHolder runat="server"></asp:PlaceHolder>

This automatically added...
Protected WithEvents RSSPlaceHolder As System.Web.UI.WebControls.PlaceHolder

to the codebehind. The codebehind is not being derived from any base class,
just System.Web.UI.Page.

To the other poster... Joseph, po is set else the code will fail where po is
used.
I actually remarked the line that uses po out and used a label which doesn't
have any variables, just text, tried to add the label and go the same prob
with that...

With what you are saying, the code should work, but it isn't working for me.
:-(

Regards,
Dave Colliver.
http://www.ManchesterFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
"Hans Kesting" wrote:
Apparently the RSSPlaceHolder is null.
This can happen if the Control *is* declared in codebehind (as
"protected", in C# terms), but there is no
<asp:PlaceHolder ID="RSSPlaceHolder" runat="server" />
in the aspx/ascx code. The ID value *must* match the name of the
control in codebehind and you *need* the runat=server attribute.
>
Another way this can happen: the codebehind is derived from some
specific baseclass where you declare that placeholder and work with it.
If you switch to design view, that declaration is added to the derived
codebehind class (the compiler will issue warnings about this
declaration hiding declarations from the baseclass)
>
Hans Kesting
>
>
Sorry, forgot to say what the error was...

Object reference not set to an instance of an object

The placeholder is on the page and has been inserted into the Web Form
Designer Generated Code region.

As you can see, the object I am trying to add to the control is also
declared.

Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available

"David Colliver" wrote:

Hi,
>
using vb.net 1.1
>
I am trying to add a control to a placeholder but am having problems with
it.
>
I do it practically the same way as i do in C# (I have more C# skill than
VB.NET)and I have asked someone with more VB experience to look at it and
they can't see why it fails.
>
Any help appreciated...
>
Dim DocRSSLiteral As New Literal
DocRSSLiteral.Text = "<link href=""" & po.DisplayPath & """
rel=""alternate"" type=""application/rss+xml"" title=""" & po.DisplayName &
""" />"
>
RSSPlaceHolder.Controls.Add(DocRSSLiteral)
>
It is failing on the PlaceHolder Controls.Add line.
>
I can remove all these lines, try and add a label or a hyperlink and they
fail in exactly the same way.
>
Thanks for your help.
>
Regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Portal franchises available
>
>
>
Nov 16 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.