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

Error modifying HtmlForm.Controls collection (templated web site)

Background:

We needed the ability to create a templated web site that may change in
layout from installation to installation. To accomplish this, we created a
base Page class that all pages in the site inherit from. In addition to
providing basic functionality and security, this Page class modifies the
HtmlForm controls collection in the deriving page to manage the page layout.
The Page class adds LiteralControls to manipulate the page layout (basically
adding table definitions around the controls that were created when
designing the child form) and adds some standard UserControls (toolbar and
login control). The layout could have been directly added to the base Page
class Controls collection, except that the UserControls contain form
elements and must be nested inside of the form (which is created as a child
control on the deriving page).

For the most part, this works well. However, if any of the controls on the
child form contain script blocks (<% %>), the control manipulation throws an
exception:

The Controls collection cannot be modified because the control contains code
blocks (i.e. <%...%>).

So the question is, what are some ways to get around this? I have seen the
suggestion of making all content user controls and only having one form.
Ultimately, this may be the way to go. However, I would prefer to continue
along this path. Is there a way to hook into the form creation and add the
controls as the form is parsed and added to the page?

Thanks,
jeff
Nov 18 '05 #1
0 1102

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

Similar topics

4
by: TS | last post by:
I am trying to create a page template. I am trying to set the value of a field to the return value from a method. What do I have to do to get m_form set to the value returned from a method? (the...
8
by: VB Programmer | last post by:
I have code that changes the bkground color of the webform on page_load. Here it is: Dim Body As New HtmlGenericControl Body = CType(Page.Controls(1), HtmlGenericControl)...
2
by: Jiho Han | last post by:
In CreateChildControls method of my Page, I am trying to see if a hidden input field is present (by id) and if not, add it to a predefined form (by id). protected override void...
0
by: VB Programmer | last post by:
I have 2 webforms. When I print out the page.Controls(1).tostring variable one says "HtmlForm", the other "HtmlGenericControl". How can I change the first one to "HtmlForm"? ?...
14
by: Laser Lu | last post by:
Hello, All, I just want to know that generally how to get the HtmlForm element in an ASP.NET Page? Can anybody help? Please:) Best regards, Laser Lu
5
by: Nathan Sokalski | last post by:
When I view my index.aspx page any time after the first time, I recieve the following error: System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize)...
3
by: Nathan Sokalski | last post by:
When I view any page in my application a second time, I recieve the following error: System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize) +313...
1
by: mwalts | last post by:
Hello all, I have to write a web part for a SharePoint 2003 server. We only have one SharePoint server, so developing directly on it isn't really viable. So I've planned to do the majority of...
2
by: Nathan Sokalski | last post by:
I am write a CompositeControl, and one of the controls being included is a Repeater. This is my first time including a templated control in a control other than a UserControl. I am not sure how to...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.