473,386 Members | 1,647 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,386 software developers and data experts.

CompareValidator problem

Hi,

I've got the same problem as described below. No answer found yet. Can
someone please help? (I'm using .NET 1.0 on my development machine and 1.1
on my webserver. Like Susanna, I only get the error on my webserver.)

TIA,
Axel Dahmen

--
I used compare validator control "ValueToCompare" in my aspx file like
this:

<asp:comparevalidator id="CompareValidator1" runat="server"
CssClass="image-caption" ValueToCompare="500,000.00"
Operator="LessThanEqual" Type="Currency" ErrorMessage="Tast inn et
tall som ikke er høyere enn 500000!" Display="Dynamic"
ControlToValidate="txtLaneSum" Text=""></asp:comparevalidator>
And it works fine on my development server. but when I have installed
this .NET application to the production server, I can not get the
ASP.NET page to work. I am given an error message as the following:

Server Error in / Application
The value '500,000.00' of the ValueToCompare property of
'CompareValidator1' cannot be converted to type 'Currency'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The value '500,000.00' of
the ValueToCompare property of 'CompareValidator1' cannot be converted
to type 'Currency'.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:
[HttpException (0x80004005): The value '500,000.00' of the
ValueToCompare property of 'CompareValidator1' cannot be converted to
type 'Currency'.]
System.Web.UI.WebControls.CompareValidator.Control PropertiesValid()
+415
System.Web.UI.WebControls.BaseValidator.Render(Htm lTextWriter
writer) +85
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter
writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter output)
+395
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1900
Any ideas/help you can offer would be greatly appreciated.

Thanks
Susanna Chen
Nov 18 '05 #1
4 2746
The current culture of the web form is used to convert from the string
"500,000.00" to a decimal value. If that culture treats "," as a decimal
place and period as a thousands separator (like many countries do), you will
get that error. Most likely your server is setup with a different default
culture than your development computer.

See the System.Globalization.CultureInfo object documention for an overview
of cultures.

See the <@ Page Culture= > attribute for setting a culture on one page.
You can also set the culture in the current thread:
System.Threading.Thread.CurrentCulture = [your CultureInfo object]

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

"Axel Dahmen" <NO*****@NoOneKnows.de> wrote in message
news:eg**************@TK2MSFTNGP11.phx.gbl...
Hi,

I've got the same problem as described below. No answer found yet. Can
someone please help? (I'm using .NET 1.0 on my development machine and 1.1
on my webserver. Like Susanna, I only get the error on my webserver.)

TIA,
Axel Dahmen

--
I used compare validator control "ValueToCompare" in my aspx file like
this:

<asp:comparevalidator id="CompareValidator1" runat="server"
CssClass="image-caption" ValueToCompare="500,000.00"
Operator="LessThanEqual" Type="Currency" ErrorMessage="Tast inn et
tall som ikke er høyere enn 500000!" Display="Dynamic"
ControlToValidate="txtLaneSum" Text=""></asp:comparevalidator>
And it works fine on my development server. but when I have installed
this .NET application to the production server, I can not get the
ASP.NET page to work. I am given an error message as the following:

Server Error in / Application
The value '500,000.00' of the ValueToCompare property of
'CompareValidator1' cannot be converted to type 'Currency'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The value '500,000.00' of
the ValueToCompare property of 'CompareValidator1' cannot be converted
to type 'Currency'.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:
[HttpException (0x80004005): The value '500,000.00' of the
ValueToCompare property of 'CompareValidator1' cannot be converted to
type 'Currency'.]
System.Web.UI.WebControls.CompareValidator.Control PropertiesValid()
+415
System.Web.UI.WebControls.BaseValidator.Render(Htm lTextWriter
writer) +85
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter
writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter output)
+395
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1900
Any ideas/help you can offer would be greatly appreciated.

Thanks
Susanna Chen

Nov 18 '05 #2
Hi, Peter,

unfortunately this is not the case. I have this problem with both, English
as well as German formatted prices. In the meantime I've found out that my
webserver converts SQL SMALLMONEY values into decimal values having a 4
digit precision. This value irritates the Validator. Here's an exact
description of the problem:
http://www.gotdotnet.com/Community/M...aspx?id=214327

Any help is quite appreciated!

TIA,
Axel Dahmen

--------------------
"Peter Blum" <PL****@Blum.info> schrieb im Newsbeitrag
news:ex**************@TK2MSFTNGP12.phx.gbl...
The current culture of the web form is used to convert from the string
"500,000.00" to a decimal value. If that culture treats "," as a decimal
place and period as a thousands separator (like many countries do), you will get that error. Most likely your server is setup with a different default
culture than your development computer.

See the System.Globalization.CultureInfo object documention for an overview of cultures.

See the <@ Page Culture= > attribute for setting a culture on one page.
You can also set the culture in the current thread:
System.Threading.Thread.CurrentCulture = [your CultureInfo object]

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

"Axel Dahmen" <NO*****@NoOneKnows.de> wrote in message
news:eg**************@TK2MSFTNGP11.phx.gbl...
Hi,

I've got the same problem as described below. No answer found yet. Can
someone please help? (I'm using .NET 1.0 on my development machine and 1.1 on my webserver. Like Susanna, I only get the error on my webserver.)

TIA,
Axel Dahmen

--
I used compare validator control "ValueToCompare" in my aspx file like
this:

<asp:comparevalidator id="CompareValidator1" runat="server"
CssClass="image-caption" ValueToCompare="500,000.00"
Operator="LessThanEqual" Type="Currency" ErrorMessage="Tast inn et
tall som ikke er høyere enn 500000!" Display="Dynamic"
ControlToValidate="txtLaneSum" Text=""></asp:comparevalidator>
And it works fine on my development server. but when I have installed
this .NET application to the production server, I can not get the
ASP.NET page to work. I am given an error message as the following:

Server Error in / Application
The value '500,000.00' of the ValueToCompare property of
'CompareValidator1' cannot be converted to type 'Currency'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The value '500,000.00' of
the ValueToCompare property of 'CompareValidator1' cannot be converted
to type 'Currency'.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:
[HttpException (0x80004005): The value '500,000.00' of the
ValueToCompare property of 'CompareValidator1' cannot be converted to
type 'Currency'.]
System.Web.UI.WebControls.CompareValidator.Control PropertiesValid()
+415
System.Web.UI.WebControls.BaseValidator.Render(Htm lTextWriter
writer) +85
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren (HtmlTextWriter
writer) +44
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTex tWriter output)
+395
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1900
Any ideas/help you can offer would be greatly appreciated.

Thanks
Susanna Chen


Nov 18 '05 #3
Be sure to do any number to string conversion using the same CultureInfo
object used by validators. That would be in
System.Threading.Thread.CurrentCulture.

For example, do convert a decimal value in 'val', pass the culture in
ToString()

decimal val = 32.12;
string vFormattedVal = val.ToString(System.Threading.Thread.CurrentCultur e)

If this is the correct answer, may I recommend you post a solution to your
thread on gotdotnet so others involved know the results.

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

"Axel Dahmen" <NO*****@NoOneKnows.de> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi, Peter,

unfortunately this is not the case. I have this problem with both, English
as well as German formatted prices. In the meantime I've found out that my
webserver converts SQL SMALLMONEY values into decimal values having a 4
digit precision. This value irritates the Validator. Here's an exact
description of the problem:
http://www.gotdotnet.com/Community/M...aspx?id=214327

Any help is quite appreciated!

TIA,
Axel Dahmen

Nov 18 '05 #4
Thanks, Peter,

actually the correct answer would be that my webserver converts val into a
string having a precision of 4 digits. If you pass 32.12 to val, ToString()
yields "32.1200". The Validator is not able to convert this value into a
Currency value because of the two trailing zeros.

I've set the correct culture in Page_Init() so the culture is not the
problem here. After changing val.ToString() into val.ToString("F2")
everything works fine. However, one question remains: Why does my
development machine convert 32.12 into "32.12" whereas my webserver converts
it into "32.1200"...

I've posted my solution to GetDotNet. Still I'm curious how I can force my
webserver to behave like my development computer and vice versa. As long as
they behave differently I can't avoid missing errors during testing and
debugging.

regards,
Axel Dahmen

-------------------------
"Peter Blum" <PL****@Blum.info> schrieb im Newsbeitrag
news:e8*************@TK2MSFTNGP11.phx.gbl...
Be sure to do any number to string conversion using the same CultureInfo
object used by validators. That would be in
System.Threading.Thread.CurrentCulture.

For example, do convert a decimal value in 'val', pass the culture in
ToString()

decimal val = 32.12;
string vFormattedVal = val.ToString(System.Threading.Thread.CurrentCultur e)
If this is the correct answer, may I recommend you post a solution to your
thread on gotdotnet so others involved know the results.

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

"Axel Dahmen" <NO*****@NoOneKnows.de> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hi, Peter,

unfortunately this is not the case. I have this problem with both, English as well as German formatted prices. In the meantime I've found out that my webserver converts SQL SMALLMONEY values into decimal values having a 4
digit precision. This value irritates the Validator. Here's an exact
description of the problem:
http://www.gotdotnet.com/Community/M...aspx?id=214327

Any help is quite appreciated!

TIA,
Axel Dahmen


Nov 18 '05 #5

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

Similar topics

1
by: edi | last post by:
Hi, Are there any differences between CompareValidator.ControlToCompare and CompareValidator.ControlToValidate? For example if I have TextBox controls: TextBox1 and TextBox2 what are the...
0
by: Sjaakie Helderhorst | last post by:
Hi, Somehow pushing an image-button doesn't trigger the CompareValidator, resulting in errors when entering string characters. Could someone please tell me what I did wrong? Thanks in advance!...
4
by: Axel Dahmen | last post by:
Hi, I've got the same problem as described below. No answer found yet. Can someone please help? (I'm using .NET 1.0 on my development machine and 1.1 on my webserver. Like Susanna, I only get...
2
by: Eric Maia | last post by:
I have a textbox (StartDateTextBox) in a UserControl on my page, that is supposed to have a date entered into it. I have a RequiredFieldValidator that has its ControlToValidate property set to the...
1
by: Ron Weldy | last post by:
I want to have a optional field on a form that can be blank but if the user enters something, it must be a number. I'm using a CompareValidator with the datatype check but if I submit the form with...
0
by: gauthier | last post by:
Hi, I'm developing a web application available in multiple languages. When we switch language (via a drop down list), we switch the culture of the current thread: ...
1
by: R.A.M. | last post by:
Hello, (Sorry for my English...) Could you help me please? I have a problem with CompareValidator control which makes the load of my page infinitive. Here's the code: Date of birth:...
0
by: R.A.M. | last post by:
Hello, (Sorry for my English...) Could you help me please? I have a problem with CompareValidator control which makes the load of my page infinitive. Here's the code: Date of birth:...
1
by: R.A.M. | last post by:
Hello, I am learning ASP.NET 2.0 and I have a problem with CompareValidator control. On .aspx page I have a control: Date of birth: <asp:TextBox ID="BirthDate" runat="server"...
1
by: R.A.M. | last post by:
Hi, I am learning .NET 2.0 and I have a problem with asp:CompareValidator. On .aspx page I have: Birth date: <asp:TextBox ID="BirthDate" runat="server" ValidationGroup="BirthDate"/> and it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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...

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.