Note that there are some explanatory texts on larger screens.

plurals
  1. POSet background-url css property to a memory image in .net
    primarykey
    data
    text
    <p>Please read about my following situation. So we have a web application in .net. Because some customers wanted to pay for some custom layout, we first started to use themes. It was ok until there were more than 10. Because after that it was difficult to maintain and more of them wanted custom design, I had to design a solution so that the user could change only a few css attributes through a front-end page. </p> <p>So when a user clicked a button a folder with its name and another css file was generated and he could change the attributes and save the new file. This file was dynamically loaded on the Page_Load on some basebage. This was ok, until more and more users payed for this and now we have tens of folders and expect hundreds. There is also the problem of rights, by default IIS doesn't have writing right to the application folder. Also the deployment process builds a new version by deleting the whole app folder and recreating one so we had to do a workaround and make a copy of this mega folder that holds the users css. And anyway, I don't like the idea of having hundreds of files not under source control.</p> <p>And now, I have a new requierement. The users to be allowed to upload a custom image to replace one of our own. So i said it is time to move evrything to the database. For basic attributes I solved it. </p> <p>I have a "mutant" aspx page:</p> <pre><code>&lt;%@ Page Language="C#" ContentType="text/css" %&gt; .labelText { color:&lt;%= WebApplication1.UserProfile.LabelColor%&gt; } </code></pre> <p>So the UserProfile class gets it's data from a table. And then in the page_load of the basepage</p> <pre><code>HtmlLink link = new HtmlLink(); link.Attributes.Add("type", "text/css"); link.Attributes.Add("rel", "stylesheet"); link.Attributes.Add("href", "~/Styles/Override.aspx"); this.Header.Controls.Add(link); </code></pre> <p>It works ok, the problem the images are used like this:</p> <pre><code>.divHeader { background: 15px 0 url("logo.gif") } </code></pre> <p>That logo.gig will be uploaded by the user,but I would like to be saved in the database. However when reading it as a stream I can't do something like:</p> <pre><code>background: 15px 0 url(WebApplication1.UserProfile.Logo) </code></pre> <p>Is there any otehr way I can specify an object in a css class?If it isn't what is the best approach? I was thinking about keeping the image in the db and also as a file, something similar to what we have now. I realize that if it were for an image control it would have been a lot easier, but this is the design now, and remaking it is a little bit troublesome Thanks for reading this novel and for any oppinions on this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload