asp.net - How to dynamically show/hide a style sheet inside a content control? -
One content inside my head tag is a master page with placeholder control, so that I can easily add any content Can add (link tags, styles, script etc etc from content pages)
Now, on one of the content pages, I have a style sheet (inline, i.e., inside a style tag, not linked to this, a link tag) that I can show / I want to hide (works like a wizard using multiview control on page page). I tried to wrap the stylesheet under the placeholder control in visible = false, then set the code to be visible to the right but that does not work, the style tag is not provided in the HTML I removed the placeholder control and styled Runat = "Server" was removed directly on the tag, but that did not work.
The reason I keep the styles hidden in the first place is that they are formatting placeholders, i.e. {0}, {1} .. ATC, which I change to the code before showing the stylesheet. I do not want to send the styles to the client with these placeholders. To make it clear, styles look like this:
& lt; ASP: Placeholder ID = "_ Style Place Holder" Runat = "Server" View = "Wrong" & gt; & Lt; Style type = "text / css" & gt; #elementid {width: {0} px; Height: {0} px; Hidden flurry; Status: Relative; } # Elementid2 {status: Completed; Width: {1} px; Height: {2} Px; Top: {3} Px; Left: {4} px; } .. and so on & lt; / Style & gt; & Lt; / ASP: Placeholder & gt;
I can try to add genres to dynamically from the code on the back of the page (for example, using Page.Header.StyleSheet.CreateStyleRule) but I did not have them .aspx file I like to keep in To separate HTML from code and also to make styles easier to change without any dynamic value.
Thank you
OK, I finally got it. First of all, there is nothing wrong with ASP.NET when I posted the question I was testing with Google Chrome. As I indicated in my comment above, I later tested with Firefox and found that the style tag is actually there.
I checked again in Chrome but this time I checked the Code Inspector instead of the page source, there is also a style tag. Chrome did not like the style tag with placeholder (I was testing, so I still replaced the placeholder) and decided to hide it from the page source view and pressed it under the rug! Good boy !!
Comments
Post a Comment