Wednesday, January 14, 2004

Ran into this little problem on I wanted the studios that work with us to be able to customize how their customers see the pages. I figured that by letting the studio set a logo image at the top of the page, a background image if they choose, and the background, text, and link colors, they would have enough flexiblity to get our site to look more like theirs.

So I figured storing those settings in a table and programatically changing them. But it's not that easy.

The logo image was simple. I gave the image an ID of img1, and put our Image Connection logo as the default. Then in the load_prefs method I simply checked to see if there was a logo saved, and if so:
img1.ImageURL = "logos/" & prefsRow("Logo") 'prefsRow being the row in the preference table cooresponding to that studio.

However, the background image an the colors was tricky. That is set in the body tag. The body HTML tag has no class associated with it specifically, so you can't simply access it's attributes.

However, you can give the body tag an ID and a 'runat=server' attribute in your HTML, and programatically declare it as an 'HtmlGenericControl' using whatever ID you gave it:
Protected bodyElement As HtmlGenericControl

Then you can simply set values using the HtmlGenericControls' attribute property as such:

Pretty slick huh!

For more info check this article out. (dotnetjunkies again)

No comments: