473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Something to watch out for

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?

Jan 3 '06 #1
1 1226
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" <td******@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro 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?

Jan 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Premshree Pillai | last post by:
Hello, I recently posted a simple Python script--Watch That Post--that lets you watch a URL for any changes. I wrote it to watch posts on LiveJournal, but it can watch any URL. It's at...
3
by: jason | last post by:
Does anyone have any ideas on a PAGE WATCH tool or an application that allows a user to be notified when page changes automatically by email. My immediate thoughts would be to use the FSO object...
3
by: Neil | last post by:
Hi, If I have the code line "DateTime d1 = DateTime.Now;" and look at d1 in the watch window, I thought I'd only see the properties of the DateTime object variable d1. However I seem to be...
7
by: Brad | last post by:
When debugging my current web project, in VS2003, I found I had lost the ability to drill down on watch objects in the Watch Window; I could only view the single value specific watch objects. ...
1
by: et | last post by:
How do I add a watch, using asp.net in visual studio, to stop the program when a value in a drop down list changes? I can add a watch through Debug, windows, watch, but there doesn't seem to be a...
6
by: Tau | last post by:
look my simple code below(vc8): double ends; ends=8.3; when i debug it, the variable ends cannot be displayed in the watch window. it just said "error: index '0' out of bound for...
3
by: Richard Carpenter | last post by:
I have a simple winform with a customers combobox, a "get orders" button and an orders grid. Due to other requirements, I have implemented the form to allow the user to select a customer from the...
20
by: James | last post by:
I am new to vb.net (I am an old vb6 programmer). I cannot figure out an easy way to watch variables. In vb6 all I did was right click and could chose to stop execution when a variable chances as...
8
by: Greg | last post by:
Dear all, I've trouble with debugging a huge programm. I want to look into the properties of an object when I am at a breakpoint. But in the watch window he tell's me that the object is "out of...
15
geolemon
by: geolemon | last post by:
I'm having a seriously Twilight Zone moment: In the code below, I'm building a SQL command into a string variable, declared at the top of my code. Then, I connect to the database and try to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.