Hello Larry,
Thanks for your code.
==================================================
2ndly the Validator for ONE of my controls is randomly incorrect.
==================================================
Do you mean the RangeValidator not work properly? From the code that you
sent me via email we can see:
<asp:RangeValidator ID="valNumInParty" runat="server"
ControlToValidate="textNumberInParty" Display="Dynamic"
ErrorMessage="1 to 20 plese" MaximumValue="20" MinimumValue="1"
ValidationGroup="AllValidators">num in party bad
</asp:RangeValidator>
By default the type of RangeValidator is String so some input such as 3
will be considered as invalid even though the MaximunValue is "20" and the
MinimumValue is "1". To get it work we need to set the type as integer or
double based on your requirement:
<asp:RangeValidator ID="valNumInParty" runat="server" Type="Integer"
ControlToValidate="textNumberInParty" Display="Dynamic"
ErrorMessage="1 to 20 plese" MaximumValue="20" MinimumValue="1"
ValidationGroup="AllValidators">num in party bad
</asp:RangeValidator>
==================================================
In particular, I am watching very intermittent behavior of my ASP page.
when I execute:
protected void buttonSubmit_Click(object sender, EventArgs e)
{
if(Page.IsValid) {
labelMessage.Text = "Your reservation has been processed.";
}
else
{
labelMessage.Text = "Page is not valid.";
}
}
the Page.IsValid is returning true even when it has produced errors that
the
Validators have caught.
==================================================
I cannot reproduce this issue. What I can see is the client validation for
CustomValidator1 is conflict with its server side validation.From the
following javascript we can see the input 1/1/1985 will be accepted:
<script language="javascript">
function validateDate(oSrc, args)
{
var iDay, iMonth, iYear;
var arrValues;
arrValues = args.Value.split("/");
iMonth = arrValues[0];
iDay = arrValues[1];
iYear = arrValues[2];
var testDate = new Date(iYear, iMonth - 1, iDay);
if ((testDate.getDate() != iDay) ||
(testDate.getMonth() != iMonth - 1) ||
(testDate.getFullYear() != iYear))
{
args.IsValid = false;
return;
}
return true;
}</script>
However,the server side validation only accepts the date format such as
01/01/1985:
protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
try {
DateTime.ParseExact(args.Value, "d", CultureInfo.InvariantCulture);
//Note, use CultureInfo.InvariantCulture instead of null as the third
parameter.
args.IsValid = true;
}
catch {
args.IsValid = false;
}
So I'm not sure what should be the valid input. Could you clarify your
requirement? If you still have this problem please send me a demo and tell
me how to reproduce this issue in detail.
==================================================
PS. Why does the project end up in MyDocs...? and the sources in another
dir?
==================================================
You're creating a Web Site instead of a Web Application project. The Web
Site will keep the page files and the sln file separate.
Please let me know if you need further assistance.
Regards,
Allen Chen
Microsoft Online Support
--------------------
| Thread-Topic: asp.net server side debugging
| thread-index: Ack/uzM/E3MYF/AXS9G3uitb6tgB/Q==
| From: =?Utf-8?B?dXNmaW5lY2F0cw==?= <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
| Subject: Re: asp.net server side debugging
| Date: Wed, 5 Nov 2008 18:56:00 -0800
| Lines: 91
| Message-ID: <
[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.3168
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Path: TK2MSFTNGHUB02.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:79312
| NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks for the reply, the validator I'm using is just the one from the
| tutorial...
| I forced some print statements to be dumped, and that just confirmed that
| values are being cached, so I'm out of the looney bin.
|
| I don't understand the caching though. If I fill in a form , then submit
| it, then edit it and submit it again I don't find that the result is
| processed correctly.
|
| I guess I'm don't understand the execution model and when things get
| processed.
| Maybe a couple pointers on that would be informative.
|
|
| --
| Gak -
| Finecats
|
|
| "Cowboy (Gregory A. Beamer)" wrote:
|
| > What kinds of validators are you using? If you have custom validators,
you
| > might have an issue there, based on how they are set up.
| >
| > Personally, I run data through a secondary validation on the server
side to
| > be safe. I like having the validation in a business component, as it is
| > portable to other forms of application faceplates (like Windows Forms
and
| > WPF/Silverlight). I cannot do this if all of the validation is buried
in the
| > ASP.NET code.
| >
| > --
| > Gregory A. Beamer
| > MVP, MCP: +I, SE, SD, DBA
| >
| > Subscribe to my blog
| >
http://feeds.feedburner.com/GregoryBeamer#
| >
| > or just read it:
| >
http://feeds.feedburner.com/GregoryBeamer
| >
| > ********************************************
| > | Think outside the box! |
| > ********************************************
| > | > > I'm new to asp.net. I'm trying to follow the tutorial walkthroughs
and
| > > have
| > > got a few done. Now I'm doing the one about validating input, and
I've
| > > run
| > > into some problems.
| > >
| > > In particular, I am watching very intermittent behavior of my ASP
page.
| > >
| > > when I execute:
| > >
| > > protected void buttonSubmit_Click(object sender, EventArgs e)
| > > {
| > > if(Page.IsValid) {
| > > labelMessage.Text = "Your reservation has been processed.";
| > > }
| > > else
| > > {
| > > labelMessage.Text = "Page is not valid.";
| > > }
| > > }
| > >
| > > the Page.IsValid is returning true even when it has produced errors
that
| > > the
| > > Validators have caught.
| > >
| > > 2ndly the Validator for ONE of my controls is randomly incorrect.
| > >
| > > So, how might I debug this? The client side is not where MY PROBLEMS
lie.
| > > I need
| > > to debug the SERVER side to understand if my properties on the
validators
| > > are not correct.
| > >
| > > Is there caching of prior data going on that I'm not aware of?
| > > How do I go about cleaning this out?
| > >
| > > How do I debug this odd/frustrating behavior?
| > >
| > > TIA
| > >
| > >
| > >
| > > --
| > > Gak -
| > > Finecats
| >
| >
|