0

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.

Donato Szilagyi
  • 4,279
  • 4
  • 36
  • 53
mona
  • 67
  • 1
  • 8

1 Answers1

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