Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Something to watch out for

Reply
Thread Tools

Something to watch out for

 
 
tdavisjr
Guest
Posts: n/a
 
      01-03-2006
I was extensively using Masterpages today and I discovered a behavior
that had me stumped for about 1/2 hour.

If you create a aspx page that uses a Masterpage and you define a text
box server control and give it an ID of txtName. Now, let say you want
to style that textbox so with css you use the ID selector to give the
textbox a style like so:

#txtName
{
color: Yellow;
}

Now, you go to run that page and the text box isn't styled the way you
want, it looks normal. This is because that when the server control in
rendered on the client it is pre-fixed with a unique name like:
_ctl0:mainContent:txtName

_ctl0 => the first control
mainContent => this is the ID I gave the content placeholder in my
MasterPage
txtName => the ID of the textbox

Therefore, the ID that is rendered in the client is NOT the same ID
selector you defined in your css and your server control don't get
styled. This behavior happens to anything you define as
runat="server", which all server controls has this attribute.

So, lessons learned. Its seems like this is where Themes and Skins
come to the rescue. OR, instead of using the ID selector in your css
use the class dot (.class ) synthax.

Anyone else had this similar experience?

 
Reply With Quote
 
 
 
 
clintonG
Guest
Posts: n/a
 
      01-04-2006
Yea me. Micrsoft breaks everything and calls it progress
I never considered much value to the singular use of the id selector as
opposed to the class selector anyway. Its Microsoft's failure to support
other selectors that are much more useful that remains problematic for the
next five years or so.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"tdavisjr" <> wrote in message
news: ups.com...
>I was extensively using Masterpages today and I discovered a behavior
> that had me stumped for about 1/2 hour.
>
> If you create a aspx page that uses a Masterpage and you define a text
> box server control and give it an ID of txtName. Now, let say you want
> to style that textbox so with css you use the ID selector to give the
> textbox a style like so:
>
> #txtName
> {
> color: Yellow;
> }
>
> Now, you go to run that page and the text box isn't styled the way you
> want, it looks normal. This is because that when the server control in
> rendered on the client it is pre-fixed with a unique name like:
> _ctl0:mainContent:txtName
>
> _ctl0 => the first control
> mainContent => this is the ID I gave the content placeholder in my
> MasterPage
> txtName => the ID of the textbox
>
> Therefore, the ID that is rendered in the client is NOT the same ID
> selector you defined in your css and your server control don't get
> styled. This behavior happens to anything you define as
> runat="server", which all server controls has this attribute.
>
> So, lessons learned. Its seems like this is where Themes and Skins
> come to the rescue. OR, instead of using the ID selector in your css
> use the class dot (.class ) synthax.
>
> Anyone else had this similar experience?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Swiss Watch International Limited Edition Moon Phase IndicatorMen's Watch A9242.S.S.A1 PinkFloyd43 Digital Photography 1 08-22-2008 01:04 PM
object = watch(object){|x| "DO SOMETHING WITH X"} Erik Veenstra Ruby 0 01-27-2006 02:09 PM
Looking for a program to run on XP to remotely watch what my kids are doing, something like a keylogger. TIA!! Tory Brown Computer Security 45 06-05-2005 03:44 PM
Words to Watch Out For Kevin Spencer ASP .Net 7 05-20-2005 06:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57