Hello to all friends
I've got a css file that I want it to be edited by an administrator
The administrator likes to get black background site and stored in the database will
But remember css file and read the value stored in the database will be in the following write css file
background-color: "# 000000"
# 000000 instead want to write something to be read from the database and any amount you can put into your site administrator putty background-color ...
I appreciate someone could help me
CSS will not access the database. There are a number of ways you could attempt to implement something like this though.
1). Allow your admin to edit the actual css file.
This can be tricky if you can't trust your admins to put in valid css code (which is pretty much all the time). You can limit it a bit by only allowing them to modify a smaller css file, or by giving a form that makes changes to the css file on their
behalf. In either case, if you went this route, there is no database integration, simply file system operations.
2). Store css in the database.
You can store css code in the database somewhere and in the Page_Load method, you could communicate with the database and pull the css code and register it using the ClientScriptManager.
3). Provide themes from which your admin selects.
Here you are only storing the theme they select from the database and loading the css file dynamically. This will limit your admin's options a bit, but sometimes that is necessary.
Note, you don't necessarily need the ClientScriptManager to dynamically load css. You could also do it inline:
That said, there will be a bit of groundwork that needs to be laid, so I'm not sure how best to help you without getting an idea of what you can and can't do as of this point.
"Dream as if you'll live forever, live as if you'll die today." --James Dean
mehdin69
0 Points
3 Posts
Css file to connect to the database
Dec 18, 2012 03:45 PM|LINK
Hello to all friends
I've got a css file that I want it to be edited by an administrator
The administrator likes to get black background site and stored in the database will
But remember css file and read the value stored in the database will be in the following write css file
background-color: "# 000000"
# 000000 instead want to write something to be read from the database and any amount you can put into your site administrator putty background-color ...
I appreciate someone could help me
AceCorban
Star
12556 Points
2313 Posts
Re: Css file to connect to the database
Dec 18, 2012 04:06 PM|LINK
CSS will not access the database. There are a number of ways you could attempt to implement something like this though.
1). Allow your admin to edit the actual css file.
This can be tricky if you can't trust your admins to put in valid css code (which is pretty much all the time). You can limit it a bit by only allowing them to modify a smaller css file, or by giving a form that makes changes to the css file on their behalf. In either case, if you went this route, there is no database integration, simply file system operations.
2). Store css in the database.
You can store css code in the database somewhere and in the Page_Load method, you could communicate with the database and pull the css code and register it using the ClientScriptManager.
3). Provide themes from which your admin selects.
Here you are only storing the theme they select from the database and loading the css file dynamically. This will limit your admin's options a bit, but sometimes that is necessary.
Note, you don't necessarily need the ClientScriptManager to dynamically load css. You could also do it inline:
That said, there will be a bit of groundwork that needs to be laid, so I'm not sure how best to help you without getting an idea of what you can and can't do as of this point.