We help IT Professionals succeed at work.

aps.net how to override body font size style at runtime

mugsey
mugsey used Ask the Experts™
on
I am switching style sheets at runtime in an asp.net app with master pages.

I am doing it via code behind in masterpage and it works fine in code below.

Now have buttons on master page for larger smaller text and need to know how to override the style class by doing something like

the body:font-size = 1.4





HtmlLink cssMasterLink = new HtmlLink();
                cssMasterLink.Href = "css/hc.css";
                cssMasterLink.Attributes.Add("rel", "stylesheet");
                cssMasterLink.Attributes.Add("type", "text/css");
                cssMasterLink.Attributes.Add("media", "screen");
                Head1.Controls.Add(cssMasterLink);

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
StephanLead Software Engineer
Commented:
why trying so hard if you can use Cookies in order to know what the state that the user has clicked. And from there (with javascript) you can set the font size.

Author

Commented:
Hi Yes

I am using cookies and yes I will use javascript to override font size

Could I have an example please?
StephanLead Software Engineer
Commented:
you can use the following jquery plugin:
http://www.shopdev.co.uk/blog/text-resizing-with-jquery/

Author

Commented:
Ok thanks but I now need it to do via code behind in master page
You can add the style-property to the buttons.
Something like <asp:LinkButton ID="x" runat="x" style="font-size=1.4" />

This will override the CSS-style for font-size.