473,406 Members | 2,549 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,406 software developers and data experts.

Adding controls to Page.Controls collection

I have run into a major road block with my page development projects. I am
trying to add a literal control to my asp.net page and I got an error
stating that the control could not be added because of code blocks (<% %>)
on the page. Most of these blocks can be handled by adding a label control
to the form so it is not that big of deal, but one of the things being
posted is the page title. I am not sure how I can access that from the code
behind page. I also call a function that creates a css style sheet as well
as a function that creates my navigation bar for the web site. Is there a
way for me to get around the error without moving the code blocks? If not,
how can I implement the changes for the three problem areas?
Nov 18 '05 #1
5 1667
Try adding a panel and then adding the control to the panel. As I have not
worked with <% %> blocks, this is just a guess, but the panel makes a better
container for controls than Page, IMO.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have run into a major road block with my page development projects. I am
trying to add a literal control to my asp.net page and I got an error
stating that the control could not be added because of code blocks (<% %>)
on the page. Most of these blocks can be handled by adding a label control
to the form so it is not that big of deal, but one of the things being
posted is the page title. I am not sure how I can access that from the code behind page. I also call a function that creates a css style sheet as well
as a function that creates my navigation bar for the web site. Is there a
way for me to get around the error without moving the code blocks? If not,
how can I implement the changes for the three problem areas?

Nov 18 '05 #2
if you are framework 1.1,

<title id=title runat=server>

will showup on the codebehind as a generic html control, which you can set
attributes or innerhtml.

-- bruce (sqlwork.com)

"Jeremy Ames" <yo******@here.com> wrote in message
news:#A**************@TK2MSFTNGP11.phx.gbl...
I have run into a major road block with my page development projects. I am
trying to add a literal control to my asp.net page and I got an error
stating that the control could not be added because of code blocks (<% %>)
on the page. Most of these blocks can be handled by adding a label control
to the form so it is not that big of deal, but one of the things being
posted is the page title. I am not sure how I can access that from the code behind page. I also call a function that creates a css style sheet as well
as a function that creates my navigation bar for the web site. Is there a
way for me to get around the error without moving the code blocks? If not,
how can I implement the changes for the three problem areas?

Nov 18 '05 #3
The literal that I am loading is Javascript. Will that work in a panel?

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:uE**************@TK2MSFTNGP11.phx.gbl...
Try adding a panel and then adding the control to the panel. As I have not
worked with <% %> blocks, this is just a guess, but the panel makes a better
container for controls than Page, IMO.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have run into a major road block with my page development projects. I am
trying to add a literal control to my asp.net page and I got an error
stating that the control could not be added because of code blocks (<% %>)
on the page. Most of these blocks can be handled by adding a label control
to the form so it is not that big of deal, but one of the things being
posted is the page title. I am not sure how I can access that from the code behind page. I also call a function that creates a css style sheet as well
as a function that creates my navigation bar for the web site. Is there a
way for me to get around the error without moving the code blocks? If not,
how can I implement the changes for the three problem areas?


Nov 18 '05 #4
What about the CSS? That is supposed to go into the head section of the
page.

"bruce barker" <no***********@safeco.com> wrote in message
news:u4**************@TK2MSFTNGP12.phx.gbl...
if you are framework 1.1,

<title id=title runat=server>

will showup on the codebehind as a generic html control, which you can set
attributes or innerhtml.

-- bruce (sqlwork.com)

"Jeremy Ames" <yo******@here.com> wrote in message
news:#A**************@TK2MSFTNGP11.phx.gbl...
I have run into a major road block with my page development projects. I am
trying to add a literal control to my asp.net page and I got an error
stating that the control could not be added because of code blocks (<% %>)
on the page. Most of these blocks can be handled by adding a label control
to the form so it is not that big of deal, but one of the things being
posted is the page title. I am not sure how I can access that from the code behind page. I also call a function that creates a css style sheet as well
as a function that creates my navigation bar for the web site. Is there a
way for me to get around the error without moving the code blocks? If not,
how can I implement the changes for the three problem areas?


Nov 18 '05 #5
When outputting javascript, Microsoft has supplied several methods on the
Page object to properly place the code and avoid getting called multiple
times. Look up RegisterStartupScript, RegisterClientScriptBlock,
IsClientScriptBlockRegistered and IsStartupScriptRegistered on the Page
class.

I don't recommend using a Panel as a place to drop any controls unless you
want its <div> wrapper. Microsoft provided the PlaceHolder control as a
place to add other controls without getting any additional HTML.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Jeremy Ames" <yo******@here.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
The literal that I am loading is Javascript. Will that work in a panel?

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:uE**************@TK2MSFTNGP11.phx.gbl...
Try adding a panel and then adding the control to the panel. As I have not
worked with <% %> blocks, this is just a guess, but the panel makes a better container for controls than Page, IMO.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Jeremy Ames" <yo******@here.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have run into a major road block with my page development projects. I am trying to add a literal control to my asp.net page and I got an error
stating that the control could not be added because of code blocks (<% %>) on the page. Most of these blocks can be handled by adding a label control to the form so it is not that big of deal, but one of the things being
posted is the page title. I am not sure how I can access that from the

code
behind page. I also call a function that creates a css style sheet as well as a function that creates my navigation bar for the web site. Is there a way for me to get around the error without moving the code blocks? If not, how can I implement the changes for the three problem areas?


Nov 18 '05 #6

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

Similar topics

2
by: Clayton Hamilton | last post by:
I have a DataGrid on a webform bound to a Datasource and can successfully use <ItemTemplate> to create edit/update/cancel functionality for user maintenance of data. I use separate logic to delete...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
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...
4
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in...
6
by: Totto | last post by:
Hi, Anyone know the best solution to dynamically add buttons to a asp 2.0 page using data from Sql server? Are there any contols suitable for this or is it best to iterate the dataset and...
0
by: sonic | last post by:
I am trying to dynamically load a validator and must be missing something elementary here. I extended TextBox control to add some functionality to it. One new feature it contains is IsRequired...
4
by: John Dalberg | last post by:
I am looking at a problem which is preventing my code to get a reference to any asp control inside a div section which has a runat=server attribute. This can be reproduced in a simple test:...
3
by: Nunzio | last post by:
I am trying to add specific form controls to a VBA collection, so that I can pass the entire collection to another function, and access the individual controls later. I have tried several...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.