开发者

Change the id of the body tag from code-behind

开发者 https://www.devze.com 2023-03-25 17:50 出处:网络
I\'m curious: Is it possible to change the the id of the开发者_StackOverflow社区 body tag from code-behind (in ASP.Net Webforms)?

I'm curious: Is it possible to change the the id of the开发者_StackOverflow社区 body tag from code-behind (in ASP.Net Webforms)?

I want to change

<body id="test">

to

<body id="foo">

without having to use a second MasterPage. (Our designer provided two different html/css files where the id of the body tag is different. Except for that small difference, I could use the same MasterPage)

Do I really need to create another MasterPage, just for the different body tag?


You can have a bodyId variable in the MasterPage:

<body id='<%= bodyId %>'>

And then you can set the variable from the content page.


ID of page elements is same as name of variables, can you change them? if yes you can do this also, if no, it's possible!


You can do it on client side too.

See here : http://jsfiddle.net/fTvpQ/2/

0

精彩评论

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