<% '******************************************************* '* ASP 101 Sample Code - http://www.asp101.com/ * '* * '* This code is made available as a service to our * '* visitors and is provided strictly for the * '* purpose of illustration. * '* * '* http://www.asp101.com/samples/license.asp * '* * '* Please direct all inquiries to webmaster@asp101.com * '******************************************************* %> <% ' Some constants for our text labels since I need ' to know their exact values when comparing them. Const strPreviewLabel = "Preview Settings" Const strSaveLabel = "Save Settings To A Cookie" ' Variables to hold the style attributes Dim strFontFamily Dim strFontSize Dim strFontStyle Dim strFontWeight Dim strFontColor ' See if we've got values coming in from the form. ' If so use them otherwise get the values from the ' cookie if they exist or just use some defaults. If Request.QueryString.Count = 0 Then ' Get settings from cookie if available O/W use defaults. If Request.Cookies("FontConfig").HasKeys Then ' Get Settings From Cookie strFontFamily = Request.Cookies("FontConfig")("family") strFontSize = Request.Cookies("FontConfig")("size") strFontStyle = Request.Cookies("FontConfig")("style") strFontWeight = Request.Cookies("FontConfig")("weight") strFontColor = Request.Cookies("FontConfig")("color") Else ' Here's where I get to set it to the format I like! strFontFamily = "Arial" strFontSize = "16pt" strFontStyle = "Italic" strFontWeight = "Bold" strFontColor = "#0000FF" End If Else strFontFamily = Request.QueryString("family") strFontSize = Request.QueryString("size") strFontStyle = Request.QueryString("style") strFontWeight = Request.QueryString("weight") strFontColor = Request.QueryString("color") ' Check to see if they wanted to save these new values. ' Make sure the form element has the name "submit" If Request.QueryString("submit") = strSaveLabel Then ' Save Settings To Cookie Response.Cookies("FontConfig")("family") = strFontFamily Response.Cookies("FontConfig")("size") = strFontSize Response.Cookies("FontConfig")("style") = strFontStyle Response.Cookies("FontConfig")("weight") = strFontWeight Response.Cookies("FontConfig")("color") = strFontColor ' Set the cookie to apply to our sample directory only ' and to expire in 5 days. These should both be changed ' to appropriate values for your implementation. Response.Cookies("FontConfig").Path = "/samples" Response.Cookies("FontConfig").Expires = DateAdd("d", 5, Date()) End If End If ' The display stuff... the only part you see and ' it's the simplest part of the code! Just set the ' parameters of the style attribute of the font element. %>

This is the text that will vary in appearence based on the settings you choose.

<% ' Now that that's done... please realize I just used this as an ' example. You could really let people change anything from ' page titles to background colors. ' You name it... you can probably do it. ' The following form can get pretty confusing but all it's really ' doing is maintaining state from request to request. %>
" method="get">

"> View using the settings saved in your cookie.