473,394 Members | 1,737 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,394 software developers and data experts.

[ASP.NET 2] ContentPlaceHolderID

hello,
I would like to create some Content server controls at runtime within
Page_InitComplete code
unfortunately I got exception :(

"Setting the ContentPlaceHolderID property of
System.Web.UI.WebControls.Content is not supported"

what can I do?
Nov 19 '05 #1
3 2562
Hi

I'm having exactely the same problem - but still no solution... Too me it
looks like a bug, but I don't hope so...

My old "unanswered question":
-------
Everything about the MasterPages loaded dynamicly, just works fine... BUT
when i try to add the Content "boxes" dynamicly to the .aspx page, I get
problems...

My code:
Dim myContent As Content = New Content()
Page.Page.Controls.Add(myContent)
myContent.ContentPlaceHolderID = "ContentPlaceHolder1"

The error:
Setting the ContentPlaceHolderID property of
System.Web.UI.WebControls.Content is not supported.

Shouldn't this work...? For me it look likes an error in the ASP.NET 2.0..?
---------

"SBerry" <xx*@xxx.net> skrev i en meddelelse
news:%2****************@TK2MSFTNGP09.phx.gbl...
hello,
I would like to create some Content server controls at runtime within
Page_InitComplete code
unfortunately I got exception :(

"Setting the ContentPlaceHolderID property of
System.Web.UI.WebControls.Content is not supported"

what can I do?

Nov 19 '05 #2
Hi again,

This time I come with GOOD news - I found a solution!

Instead of making the Content control, you can just access the
ContentPlaceHolder's from the MasterPage and add your content this way -
still at runtime...

Like this:
---
Dim PlaceHolder1 As ContentPlaceHolder =
Master.FindControl("ContentPlaceHolder1")
Dim lblTxt As Label = New Label()
lblTxt.Text = "Text for ContentPlaceHolder1"
PlaceHolder1.Controls.Add(myTextHolder)
---

This works for me - damn I'm happy - good luck and enjoy!

/Stendal

"SBerry" <xx*@xxx.net> skrev i en meddelelse
news:%2****************@TK2MSFTNGP09.phx.gbl...
hello,
I would like to create some Content server controls at runtime within
Page_InitComplete code
unfortunately I got exception :(

"Setting the ContentPlaceHolderID property of
System.Web.UI.WebControls.Content is not supported"

what can I do?

Nov 19 '05 #3
There was a little bug in the code, so here comes a functional version:
---
Dim PlaceHolder1 As ContentPlaceHolder =
Master.FindControl("ContentPlaceHolder1")
Dim lblTxt As Label = New Label()
lblTxt.Text = "Text for ContentPlaceHolder1"
PlaceHolder1.Controls.Add(lblTxt)
---

/Stendal

"Casper Stendal" <cs***@VEecreo.dk> skrev i en meddelelse
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi again,

This time I come with GOOD news - I found a solution!

Instead of making the Content control, you can just access the
ContentPlaceHolder's from the MasterPage and add your content this way -
still at runtime...

Like this:
---
Dim PlaceHolder1 As ContentPlaceHolder =
Master.FindControl("ContentPlaceHolder1")
Dim lblTxt As Label = New Label()
lblTxt.Text = "Text for ContentPlaceHolder1"
PlaceHolder1.Controls.Add(myTextHolder)
---

This works for me - damn I'm happy - good luck and enjoy!

/Stendal

"SBerry" <xx*@xxx.net> skrev i en meddelelse
news:%2****************@TK2MSFTNGP09.phx.gbl...
hello,
I would like to create some Content server controls at runtime within
Page_InitComplete code
unfortunately I got exception :(

"Setting the ContentPlaceHolderID property of
System.Web.UI.WebControls.Content is not supported"

what can I do?


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Adam Tibi | last post by:
Hello, I have this: MasterPage 1: <asp:ContentPlaceHolder ID="cphHead" runat="server"> </asp:ContentPlaceHolder> Some Html... <asp:ContentPlaceHolder ID="cphBody1" runat="server">...
3
by: Developer in California | last post by:
I am working on developing a generic Web framework using Master Pages in ASP.NET 2.0. What I have done is created a PageRenderer class which has a public method which will retrieve the path of the...
2
by: Dynamo | last post by:
Hi there, I have a curious problem I can't seem to solve. I have a list box that gets filled with data, the user selects an item in this list, then a form view displays the full details from...
2
by: Sasquatch | last post by:
I'm having trouble creating a simple login page using the asp:login control. I followed some instructions in a WROX book, "Beginning ASP.NET 2.0," and the instructions are very straight forward,...
9
by: RBM007 | last post by:
Hello, I have created some pages in the (old) Atlas pages and migrated to AJAX version. After the update I noticed that any page containing ASP.NET AJAX won't compile anymore. Even if the same...
0
by: dixonjm | last post by:
Hi, I have a master page & various pages that will use this master page. Each content page will have a CSS & JS file which will be named the same as the content page. When I try to load the CSS...
1
by: anilkumar1980 | last post by:
Hi All, Here I need help to all of u, I am using ASP.NET 2.0 and Third party Infragistic Controls. I Have included master page in my page (<%@ Page Language="VB"...
1
by: E11esar | last post by:
Hi there. I have created an asp.net page with C# and have added two tabs using the respective AJAX control. I am trying to add a table within an AJAX Accordion control in the second tab but I am...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.