Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm creating a content management system where a user can select a css file from their server and the application will parse and store the css. The application will need to be able to parse the css classes out, record them, and store the css content to be dynamically added to another page where a user can select the different css classes from a drop down. So does anyone know of a way to add css content to a page dynamically, for example from a database? I've found a few projects for parsing the css, here .

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
233 views
Welcome To Ask or Share your Answers For Others

1 Answer

Make a controller which serves the CSS content:

<link rel="stylesheet" href="@Url.Action("GetCss", "Serve", new {id="filename"})" />

Controller code:

public class ServeController: Controller
{
    public ContentResult GetCss(string id)
    {
        string cssBody = GetCssBodyFromDatabase(id);
        return Content(cssBody, "text/css");
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...