473,322 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Can't add to placeholder

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
6 2076
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alexandre Martins | last post by:
what can i do with placeholder ?? tks
4
by: blue | last post by:
I have a drop-down list, a radio button list and a submit button. I'm adding these controls to a table and I'm adding the table to a Placeholder. I'm adding it to the Placeholder because I don't...
1
by: Dan | last post by:
I have an asp.net page default.aspx with a user control and a placeholder control. <html> <body> <form id="myform" method="post" runat="server" /> <PageHeader:Header id="header1"...
2
by: Ben de Vette | last post by:
Hi, I like to load a UserControl onto a placeholder with some more control then just doing protected System.Web.UI.WebControls.PlaceHolder placeHolder; UserControl ascx =...
0
by: dkode | last post by:
Hello, I know this can be done, but it's beyond me at the moment, Here is my inheritance chain: class NavRole : UserControl { protected void AddSubmenu(string submenuFile); } class artist...
0
by: dkode | last post by:
Hello, I know this can be done, but it's beyond me at the moment, Here is my inheritance chain: class NavRole : UserControl { protected void AddSubmenu(string submenuFile);
1
by: IndyChris | last post by:
I am attempting to add a drill down datagrid to my webpage so the user will not have to leave the page to get further information on a row. There are 12 other columns before this column....
7
by: Brad Baker | last post by:
I am trying to programmatically set a placeholder control in csharp which is nested inside a repeater control between <ItemTemplateand </ItemTemplate> tags, however I am running into problems. I've...
0
by: F | last post by:
Hi, The funniest part of the problem described here is that I am not new to ASP.NET, but honestly here I have no idea about what's going on. I have a GridView with a data source that just...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.