I have created a user control. I want to use CSS classes in this, but no CSS is working here. I tried registering CSS in master page, user control. But nothing worked.
Asked
Active
Viewed 1,090 times
0
-
You have to provide with more details. Have you tried looking at the css references at run-time using FireBug or some similar tool? There shouldn't be much effort to use a control specific css style. Although I must say I disencourage you to do it. – Guilherme Duarte Jan 20 '12 at 08:04
-
yaa i have tried firebug but the class i create is shown blank....but in my stylesheet that class with some attributes exist – mona Jan 20 '12 at 08:08
-
http://stackoverflow.com/q/34390/284240 – Tim Schmelter Jan 20 '12 at 08:09
-
Have you refreshed the cache(`STRG+F5`)? – Tim Schmelter Jan 20 '12 at 08:10
-
Ok, so the problem should be in the css file or in the way you use to reference it. Are you registering it in the header section? – Guilherme Duarte Jan 20 '12 at 08:24
1 Answers
0
As your usercontrol gets rendered in the containing page, you can use css on it like on any other tag on your website. The only thing you need to do is add the css file to the header of you masterpage.
When using css selectors tho, remember that the ID's of the controls on your usercontrol is not this one you should use as your css selector.
fe.
<input type='text' id='txtName'/>
in your usercontrol will be rendered to something like
<input type='text' id='ctl00_phMain_MyUserControl_txtName' />
so make sure you use the correct id to apply your style or use the class tag

stvn
- 1,148
- 1
- 8
- 24
-
The ids will only get messed for server controls? He can use the CssClass attribute for server controls. – Zo Has Jan 20 '12 at 09:28