Write into <HEAD></HEAD> section?

A

Alessandro Zifiglio

hi Jiho,
try <head id="head1" runat="server"></head>

delcare head1 as an HtmlControls.HtmlGenericControl
and then access it from code.
 
V

Victor Garcia Aprea [MVP]

Hi Jiho,

Add a runat="server" attribute to the <head> tag, then refer it in your
codebehind by its ID and you're ready to go... (the IDE will wipe off your
<head> tag from time to time...)

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
 
J

Jiho Han

Thanks guys for your help.

Victor Garcia Aprea said:
Hi Jiho,

Add a runat="server" attribute to the <head> tag, then refer it in your
codebehind by its ID and you're ready to go... (the IDE will wipe off your
<head> tag from time to time...)

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
 
S

Sam Fields

Jiho was looking to write a <link> tag. I've attempted this myself. I can
successfully write the <link> tag, but it does not work to access the .css
file and render the styles at design time. Run-time is perfectly fine.

Any clue how to get a programmatically added <link> tag to successfully
render the css styles?

Thanks!
Sam Fields
 
J

Jiho Han

Sam,

I don't know what you mean by your question. Are you trying to have the css
"rendered" at design-time? I don't know if that's possible. For example, I
tried to set the bgcolor of the BODY tag but it had no effect on the
designer window. I would guess that's probably the same behavior you can
expect with the css at design-time.

In any case, I decided not to use the LINK in my control. After all, as a
control developer, I can't control whether the page developer specifies
runat="server" attribute on the HEAD tag. Instead I have decided to add the
necessary tags via client script block. RegisterClientScriptBlock method
works fine for me in this case.

Thanks all for your help!
Jiho
 
S

Sam Fields

It acutally applies all the styles at design-time, but only if the <link>
tag is added to the top of the aspx page, and not added programmatically.
For this same reason, I abandoned adding <link> tags in my controls as well.
Anyway, thanks for your response!

Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,082
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top