By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Adding controls to Page.Controls collection

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.