473,498 Members | 1,833 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom Page Class

I have a custom page class that adds a menu onto any page that inherits it.
It works fine on a simple page but when I try to implement it on an
exisiting, more complex page I get the error "A control cannot modify its
parents' control collections. " on the following line;

Me.Controls.Add(Header)

In the aspx page I delete all the HTML code and place a panel on the page as
a placeholder. Since it works on a simple page, there's obviously something
about this particular page that's making it fail. I guess I'm looking for a
more high-level explanation of what might cause this issue.

'Base Class Method
Protected Overrides Sub CreateChildControls()

'Write out the title and link up the stylesheet
Dim sbHeader As New System.Text.StringBuilder
With sbHeader
.Append("<html><head> <title>" & strTitle & "</title>")
.Append(LinkStyleSheet)
.Append("</head>")
End With

Header.Text = sbHeader.ToString
Me.Controls.Add(Header)

Me.Controls.Add(Form)

CTMB.ExecuteSecurity = bExecuteSecurity
Form.controls.add(CTMB)

'You need to put a panel on the page to hold everything that you
want displayed in the form
Dim Main As Control = Me.Controls(0) 'Me.FindControl("Main")

If Not Main Is Nothing Then
Me.Form.controls.add(Main)
End If

Me.Form.controls.add(CBMB)

'Close of the HTML
Dim sbFooter As New System.Text.StringBuilder
With sbFooter
.Append("</body></html>")
End With

Footer.Text = sbFooter.ToString
Me.Controls.Add(Footer)

MyBase.CreateChildControls()

End Sub
Nov 17 '05 #1
0 1039

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

Similar topics

3
10808
by: Joe Bloggs | last post by:
Does anyone know if its possible to pass parameters or the values of Request.QueryString from a web page to a custom control class? I'm using a C# Web Application. For Example I have Web Page1...
6
3240
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
3
3735
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page...
7
2198
by: Joe Rigley | last post by:
Hi, I have a custom class with a public method. I want to perform a repose.redirect if an error occurs in the public method GetUserRoles. Unfortunately, Visual Studio 2003 is throwing an error...
6
3785
by: Tabi | last post by:
Hi, I want to create a custom section in my web.config that can hold my custom values. I created a section in web.config as written below. <configSections> <section name="myCustomSection"...
7
4730
by: John Grandy | last post by:
My ASP.NET Web Service project has a Web Method that returns an array filled with instances of a custom class. The custom class is defined in a Class Library that is included in the web-service...
0
1475
by: hamstak | last post by:
I had developed a custom base page class for the 1.1 framework which I have now migrated to the 2.0 framework. I discovered that the new partial class system -- which appears to "automagically"...
4
2770
by: Suresh | last post by:
Is there any way to access the custom properties of a master page from the aspx form? I know the custom properties of a master page can be accessed from the aspx.cs partial class by specifying...
2
2717
by: Michal Valent | last post by:
I would like to fire some custom server control event before Page_Load event like this (from the trace of an aspx page) : Trace Information Category Message From First(s) From Last(s) aspx.page...
4
2462
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
7125
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
7004
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7167
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
7208
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3095
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.