473,503 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validators not seeming to use CSSClass

Are Validators able to use CSSClass?

I have the following:

<asp:RegularExpressionValidator
ControlToValidate="txtEmail" CssClass="errorMessage"
Text = "Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtEmail"
CssClass="errorMessage"
Text="You must enter an email"
runat="server" />

The class is defined as:

..errorMessage{
font-size:14;
color:#00FFFF;
}

I still get the text at the old size and large.

Thanks,

Tom
Nov 19 '05 #1
6 2523
By default, the ForeColor property is set to Red on a validator. Unless you
clear it, it will write out the style="color:red" attribute into the
validator's <span> tag. That overrides your class.

As for the font size, its possible that you need to change it so its defined
in points.
font-size:14pt;

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
Are Validators able to use CSSClass?

I have the following:

<asp:RegularExpressionValidator
ControlToValidate="txtEmail" CssClass="errorMessage"
Text = "Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtEmail"
CssClass="errorMessage"
Text="You must enter an email"
runat="server" />

The class is defined as:

.errorMessage{
font-size:14;
color:#00FFFF;
}

I still get the text at the old size and large.

Thanks,

Tom

Nov 19 '05 #2
tshad wrote:
Are Validators able to use CSSClass?

I have the following:

<asp:RegularExpressionValidator
ControlToValidate="txtEmail" CssClass="errorMessage"
Text = "Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtEmail"
CssClass="errorMessage"
Text="You must enter an email"
runat="server" />

The class is defined as:

.errorMessage{
font-size:14;
color:#00FFFF;
}

I still get the text at the old size and large.

Thanks,

Tom


You might need to specify "14pt" as the font-size,
instead of just "14".

Try adding a ForeColor=" " to the control definition,
as this seems to default to "Red", overriding your css setting.

--
Hans Kesting
Nov 19 '05 #3
"Peter Blum" <PL****@Blum.info> wrote in message
news:OQ**************@TK2MSFTNGP14.phx.gbl...
By default, the ForeColor property is set to Red on a validator. Unless
you clear it, it will write out the style="color:red" attribute into the
validator's <span> tag. That overrides your class.
How do I clear it so it doesn't override my class?

I thought that was the whole point of CSSClass, to override whatever
defaults were aleady in place.

As for the font size, its possible that you need to change it so its
defined in points.
font-size:14pt;
Wasn't that what I was doing?

Tom
--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
Are Validators able to use CSSClass?

I have the following:

<asp:RegularExpressionValidator
ControlToValidate="txtEmail" CssClass="errorMessage"
Text = "Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtEmail"
CssClass="errorMessage"
Text="You must enter an email"
runat="server" />

The class is defined as:

.errorMessage{
font-size:14;
color:#00FFFF;
}

I still get the text at the old size and large.

Thanks,

Tom


Nov 19 '05 #4
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:ex**************@TK2MSFTNGP09.phx.gbl...
tshad wrote:
Are Validators able to use CSSClass?

I have the following:

<asp:RegularExpressionValidator
ControlToValidate="txtEmail" CssClass="errorMessage"
Text = "Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtEmail"
CssClass="errorMessage"
Text="You must enter an email"
runat="server" />

The class is defined as:

.errorMessage{
font-size:14;
color:#00FFFF;
}

I still get the text at the old size and large.

Thanks,

Tom
You might need to specify "14pt" as the font-size,
instead of just "14".

Try adding a ForeColor=" " to the control definition,
as this seems to default to "Red", overriding your css setting.

Actually, I made a mistake. The text wasn't large, it was the same size as
always. As Peter mentioned, the Forecolor is in the span object - but the
size isn't. So it seems the Validators don't take the CSSClasses at all,
even though MS Documentation says it does.

I did add the ForeColor and Font-Size directly on the object now and it
works fine:

<asp:RegularExpressionValidator
ControlToValidate="txtEmail" Forecolor="#00FFCC"
Font-Size="14"
Text = "Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />

The problem is I wanted to use classes so that all my error messages were
consistant (which is one of the reasons to use CSS).

Thanks,

Tom --
Hans Kesting

Nov 19 '05 #5
tshad wrote:
"Peter Blum" <PL****@Blum.info> wrote in message
news:OQ**************@TK2MSFTNGP14.phx.gbl...
By default, the ForeColor property is set to Red on a validator. Unless
you clear it, it will write out the style="color:red" attribute into the
validator's <span> tag. That overrides your class.

How do I clear it so it doesn't override my class?


Like I said before: use ForeColor=" "
I thought that was the whole point of CSSClass, to override whatever
defaults were aleady in place.

The forecolor that is specified by default in the <span> has a higher
priority than a forecolor specified in the css. Yes, css overrides
defaults, but only "real" defaults: settings that are used if you
don't specify anything. This "red" is specified in the rsulting html.
As for the font size, its possible that you need to change it so its
defined in points.
font-size:14pt;

Wasn't that what I was doing?


No, as I said before, you only used "14", not "14pt".

Tom
--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...
Are Validators able to use CSSClass?

I have the following:

<asp:RegularExpressionValidator
ControlToValidate="txtEmail" CssClass="errorMessage"
Text = "Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtEmail"
CssClass="errorMessage"
Text="You must enter an email"
runat="server" />

The class is defined as:

.errorMessage{
font-size:14;
color:#00FFFF;
}

I still get the text at the old size and large.

Thanks,

Tom



--
Hans Kesting
Nov 19 '05 #6
"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:uG**************@TK2MSFTNGP15.phx.gbl...
tshad wrote:
"Peter Blum" <PL****@Blum.info> wrote in message
news:OQ**************@TK2MSFTNGP14.phx.gbl...
By default, the ForeColor property is set to Red on a validator. Unless
you clear it, it will write out the style="color:red" attribute into the
validator's <span> tag. That overrides your class.

How do I clear it so it doesn't override my class?


Like I said before: use ForeColor=" "
I thought that was the whole point of CSSClass, to override whatever
defaults were aleady in place.


The forecolor that is specified by default in the <span> has a higher
priority than a forecolor specified in the css. Yes, css overrides
defaults, but only "real" defaults: settings that are used if you
don't specify anything. This "red" is specified in the rsulting html.


But that is my point.

People have been ragging about using CSS and seem to get bent out of shape
when you don't. Older attributes are getting deprecated.

Now, it seems, you need to use both.

Is there a place to go where it specifies when you can use CSS styles and
when you can't.

MS Website has the property CSSClass. What is the point of going through
the excercise of setting up CSS styles so you can be consistent, just to
find out later that you need to go and change attributes for selected
objects (even though you are told that those object use CSS).

I am not trying to be difficult or argumentative here, just trying to find
out the best way to build my pages and code in the best and most efficient
manner.

Thanks,

Tom
As for the font size, its possible that you need to change it so its
defined in points.
font-size:14pt;

Wasn't that what I was doing?


No, as I said before, you only used "14", not "14pt".

Tom
--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uE**************@TK2MSFTNGP09.phx.gbl...

Are Validators able to use CSSClass?

I have the following:

<asp:RegularExpressionValidator
ControlToValidate="txtEmail" CssClass="errorMessage"
Text = "Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtEmail"
CssClass="errorMessage"
Text="You must enter an email"
runat="server" />

The class is defined as:

.errorMessage{
font-size:14;
color:#00FFFF;
}

I still get the text at the old size and large.

Thanks,

Tom


--
Hans Kesting

Nov 19 '05 #7

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

Similar topics

1
2000
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
0
1893
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
6
1611
by: Mark | last post by:
We have Validators embedded in an asp table server control. The table server control is necessary and cannot be replaced. We want to apply CSS formatting to the validators, but the validators...
4
1872
by: Ian Cox | last post by:
I have a web form that contains a Datagrid. This grid has a number of columns, one of which contains a text box and validator for that text box. Everything works fine, when I press the "Save"...
4
2062
by: Luis Esteban Valencia | last post by:
I have a asp.net page (C#), with a datagrid. I use template for all columns, and have <asp:requiredfieldvalidator> in with one of the textboxes, to make sure it's filled in. However, this...
5
1645
by: John Abbler | last post by:
I'm currently testing doing some testing with other browsers and have found that my custom field validators aren't firing with Firefox or Netscape, but they work fine with Ie. Here's the code...
7
1881
by: Abraham Luna | last post by:
how do i stop the dynamic validators from breaking explorer if i use a dynamic validator and move to a different control it breaks explorer and i can type in the page when i'm not supposed to....
4
1325
by: Dabbler | last post by:
I have RequiredFieldValidators which are displacing my layout before the validator is used. This only happens in IE, Firefox renders the page correctly. Sample useage: <asp:Label...
5
1530
by: shapper | last post by:
Hello, Is there any way to make ASP.NET validators to display as block? I tried everything I could think off with skins, css, etc. I really don't know what else to try. Shouldn't this be...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7323
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...
1
6984
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...
0
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5005
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.