开发者

suggest ways to provide the user the choice to change the font size of page using c# and css to any digit possible

well

i have a asp.net aspx page, which references a css file

  • have the font size defined in css as 2em;

problem

  • want to give option to user to change this to any value he wishes

irrespective of the bad effect to display format

question

please suggest ways to achieve it easily, efficiently and the most simplest way possible

note

way开发者_如何学JAVA should support all browsers


You need to modify the CSS based on user actions. 2 approaches spring to mind:

1) Do the modification on the server (in C#). So you need to dynamically serve the CSS and modify this line based on user settings

2) Do the modification on the client using javascript (easy enough with jquery for example).

Advantage of 1 is you can store user preferences server side. But then it's easy enough to store preferences in cookies if you use javascript.


The very nice way of doing this is

create a config entry in the appsettings

<add key="CSSFontSize" value="10"/>

Have a div tag in your aspx page

<div id="cssConfigValue" style="display:none">value goes here</div> div to hold the value from config setting

in your c# code set the div through innerhtml

cssconfigValue.innerHtml="value from config"

Now in jquery , read this value and modify it

var value = $('#cssConfigValue').text() // this gives the value

$('.targeclass').css('font-size',value);

If you want to change all you need to change the appsettings and there is no need to change anything for deployment.

no dotnet build no javascript change...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜