?
Solved

ASP.net 2.0 embedding a Style sheet header!

Posted on 2008-06-12
3
Medium Priority
?
260 Views
Last Modified: 2013-11-26
I need to add code like the following to the header programmatically using asp.net 2.0:
<STYLE TYPE="text/css">
<!--
      BODY      {background: #FFFFD8;
             margin-top: 20}
-->
</STYLE>
Another note: the header code is being grabbed dynamically from a sql server based on whatever the user has stored.
Thanks, Chris.
0
Comment
Question by:jumpstart0321
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 2000 total points
ID: 21776182
you could put something like this in the page load
 Dim css As String = "BODY {background-color: #FFFFD8; margin-top: 20}" 'Load css from db
        Dim myheader As HtmlHead = Page.Header
        If (Not css = Nothing And css.Length > 0) Then
            Dim litcss As Literal = New Literal()
            litcss.Text = "<style type='text/css'>" & css & "</style>"
            myHeader.Controls.Add(litcss)
        End If

Open in new window

0
 
LVL 21

Expert Comment

by:naspinski
ID: 21776184
I would recommend using a masterpage with a

    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>

In the head, then in your page (which uses the master)

You simply include:

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
  <style type="text/css">
    <asp:Literal ID="style" runat="server" />
  </style>
</asp:Content>

Then you can manipulate style behind the scenes.

Or if you prefer, you could just use:

<style type="text/css">
    <asp:Literal ID="style" runat="server" />
</style>

inside your head for each page (the materpage would be to reduce redundancy)
0
 

Author Closing Comment

by:jumpstart0321
ID: 31466827
Thanks man :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question