21.5. Dynamically Creating Browser-Specific Stylesheets
You need to vary the look and feel of your application pages depending on the platform (Mac or Windows) being used.
asp:Literal control in the head section of the .aspx file, and then set the text property of the control to an HTML style element created programmatically in the code-behind. Use the properties of the
Request.Browser object to determine the platform type and control the generation of the style element.
In the .aspx file, place an
asp:Literal control in the head section.
In the code-behind class for the page, use the .NET language of your choice to:
Platformproperty of the
Request.Browserobject to obtain the browser’s platform.
Check the platform string for the presence of the substring, such as "
mac“, which indicates whether the browser is running on a Mac platform.
Based on the platform, programmatically create the HTML style element.
Textproperty of the
asp:Literalcontrol in the head section of the .aspx file to the created HTML style elements.
HTML is not always rendered the same. Different browsers and platforms render the HTML in various ways. This sometimes requires using a different stylesheet as a function of the browser or platform the browser is running on (Windows, Mac, etc.) to get the same visual effect. Refer to the