PC Review


Reply
Thread Tools Rate Thread

CustomValidator in GridView getting "no message" on errors

 
 
doug
Guest
Posts: n/a
 
      13th Mar 2008
I have a gridview and have placed customvalidator controls in it.
If I put a break on the sub to do custom validation, run the page, select a
row and press the EDIT button, putting me into Update/Cancel mode, I can edit
the date textbox putting in garbage and press update. It takes the
breakpoint, I step thru, it sets value.isValid=False, and when I exit
routine, same sub fires again (hits same break point) and flow values same
path. Garbage date value still there. If I continue on now, it displays the
gridview, original value of date textbox is back, my error message is not
displayed, but I'm still in Update/Cancel mode,not Edit mode so the update
didn't take place.

<asp:TemplateField HeaderText="Date Stamp"
SortExpression="date_stamp">
<EditItemTemplate>
<asp:CustomValidator ID="Date_Stamp_Update_Validator"
runat="server"
ControlToValidate="Date_Stamp_Update_Txt"
OnServerValidate="Date_Stamp_Update_Txt_Validate"
ValidateEmptyText="true"
Display="Static"
SetFocusOnError="true"
ErrorMessage="Must be YYYY-MM-DD!" ></asp:CustomValidator>
<asp:TextBox ID="Date_Stamp_Update_Txt" runat="server"
Text='<%# Bind("date_stamp") %>'
BorderStyle="Ridge" BackColor="LightYellow"
MaxLength="10" Width="65px"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Date_Stamp_Label" runat="server"
Text='<%# Bind("date_stamp") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Bottom" Width="9%"
Wrap="True"/>
<HeaderStyle VerticalAlign="Bottom" />
</asp:TemplateField>


Protected Sub Date_Stamp_Update_Txt_Validate(ByVal sender As Object, ByVal
value As ServerValidateEventArgs)
' Must be YYYY-MM-DD Format:
If value.Value.ToString.Length = 10 Then
Dim dte As DateTime
If DateTime.TryParse(value.Value, dte) Then
value.IsValid = True
Else
value.IsValid = False
End If
Else
value.IsValid = False
End If
End Sub


 
Reply With Quote
 
 
 
 
Steven Cheng
Guest
Posts: n/a
 
      14th Mar 2008
Hi dmartin,

From your description, you found that the custom validator in GridView not
work correctly , correct?

I've made a simple test on my side and got a customValidator working (with
server-side validation) in GridView templateField. I've compared the code
and aspx template between my test page and yours. It seems there is no
definte difference. I suggest you try the following things:

** explicitly turn off client-side validation(disable client script)

** Try changing your validation handler in codebehind, use some very simple
code logic to see whether it work.

Here is my test page's aspx and codebehind function for your reference:


=======aspx ....==
..............
<asp:TemplateField HeaderText="name" SortExpression="name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("name") %>'></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1"
runat="server" ErrorMessage="CustomValidator"
ControlToValidate="TextBox1"
EnableClientScript="False"

onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
=============


===========
protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (!args.Value.Contains("Name"))
args.IsValid = false;
else args.IsValid = true;

}
=============

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Thread-Topic: CustomValidator in GridView getting "no message" on errors
>thread-index: AciFTXs6Q1/KAGdKQoegfeOqrsqbfg==
>X-WBNR-Posting-Host: 171.159.64.10
>From: =?Utf-8?B?ZG91Zw==?= <(E-Mail Removed)>
>Subject: CustomValidator in GridView getting "no message" on errors
>Date: Thu, 13 Mar 2008 14:02:00 -0700


>
>I have a gridview and have placed customvalidator controls in it.
>If I put a break on the sub to do custom validation, run the page, select

a
>row and press the EDIT button, putting me into Update/Cancel mode, I can

edit
>the date textbox putting in garbage and press update. It takes the
>breakpoint, I step thru, it sets value.isValid=False, and when I exit
>routine, same sub fires again (hits same break point) and flow values same
>path. Garbage date value still there. If I continue on now, it displays

the
>gridview, original value of date textbox is back, my error message is not
>displayed, but I'm still in Update/Cancel mode,not Edit mode so the update
>didn't take place.
>
> <asp:TemplateField HeaderText="Date Stamp"
>SortExpression="date_stamp">
> <EditItemTemplate>
> <asp:CustomValidator ID="Date_Stamp_Update_Validator"
>runat="server"
> ControlToValidate="Date_Stamp_Update_Txt"
> OnServerValidate="Date_Stamp_Update_Txt_Validate"
> ValidateEmptyText="true"
> Display="Static"
> SetFocusOnError="true"
> ErrorMessage="Must be YYYY-MM-DD!" ></asp:CustomValidator>
> <asp:TextBox ID="Date_Stamp_Update_Txt"

runat="server"
>Text='<%# Bind("date_stamp") %>'
> BorderStyle="Ridge" BackColor="LightYellow"
> MaxLength="10" Width="65px"></asp:TextBox>
> </EditItemTemplate>
> <ItemTemplate>
> <asp:Label ID="Date_Stamp_Label" runat="server"
>Text='<%# Bind("date_stamp") %>'></asp:Label>
> </ItemTemplate>
> <ItemStyle HorizontalAlign="Left" VerticalAlign="Bottom"

Width="9%"
>Wrap="True"/>
> <HeaderStyle VerticalAlign="Bottom" />
> </asp:TemplateField>
>
>
> Protected Sub Date_Stamp_Update_Txt_Validate(ByVal sender As Object,

ByVal
>value As ServerValidateEventArgs)
> ' Must be YYYY-MM-DD Format:
> If value.Value.ToString.Length = 10 Then
> Dim dte As DateTime
> If DateTime.TryParse(value.Value, dte) Then
> value.IsValid = True
> Else
> value.IsValid = False
> End If
> Else
> value.IsValid = False
> End If
> End Sub
>
>
>


 
Reply With Quote
 
doug
Guest
Posts: n/a
 
      14th Mar 2008
I added EnableClientScript="false", already had the "onservervalidate=xxx".
This is the routine that is being fired twice, and each time isPostBack is
true, and it fails edit setting isValid="false".

Why is this routine fired twice - seemingly one after the other?

""Steven Cheng"" wrote:

> Hi dmartin,
>
> From your description, you found that the custom validator in GridView not
> work correctly , correct?
>
> I've made a simple test on my side and got a customValidator working (with
> server-side validation) in GridView templateField. I've compared the code
> and aspx template between my test page and yours. It seems there is no
> definte difference. I suggest you try the following things:
>
> ** explicitly turn off client-side validation(disable client script)
>
> ** Try changing your validation handler in codebehind, use some very simple
> code logic to see whether it work.
>
> Here is my test page's aspx and codebehind function for your reference:
>
>
> =======aspx ....==
> ..............
> <asp:TemplateField HeaderText="name" SortExpression="name">
> <EditItemTemplate>
> <asp:TextBox ID="TextBox1" runat="server" Text='<%#
> Bind("name") %>'></asp:TextBox>
> <asp:CustomValidator ID="CustomValidator1"
> runat="server" ErrorMessage="CustomValidator"
> ControlToValidate="TextBox1"
> EnableClientScript="False"
>
> onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
> </EditItemTemplate>
> <ItemTemplate>
> <asp:Label ID="Label1" runat="server" Text='<%#
> Bind("name") %>'></asp:Label>
> </ItemTemplate>
> </asp:TemplateField>
> =============
>
>
> ===========
> protected void CustomValidator1_ServerValidate(object source,
> ServerValidateEventArgs args)
> {
> if (!args.Value.Contains("Name"))
> args.IsValid = false;
> else args.IsValid = true;
>
> }
> =============
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> (E-Mail Removed).
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> --------------------
> >Thread-Topic: CustomValidator in GridView getting "no message" on errors
> >thread-index: AciFTXs6Q1/KAGdKQoegfeOqrsqbfg==
> >X-WBNR-Posting-Host: 171.159.64.10
> >From: =?Utf-8?B?ZG91Zw==?= <(E-Mail Removed)>
> >Subject: CustomValidator in GridView getting "no message" on errors
> >Date: Thu, 13 Mar 2008 14:02:00 -0700

>
> >
> >I have a gridview and have placed customvalidator controls in it.
> >If I put a break on the sub to do custom validation, run the page, select

> a
> >row and press the EDIT button, putting me into Update/Cancel mode, I can

> edit
> >the date textbox putting in garbage and press update. It takes the
> >breakpoint, I step thru, it sets value.isValid=False, and when I exit
> >routine, same sub fires again (hits same break point) and flow values same
> >path. Garbage date value still there. If I continue on now, it displays

> the
> >gridview, original value of date textbox is back, my error message is not
> >displayed, but I'm still in Update/Cancel mode,not Edit mode so the update
> >didn't take place.
> >
> > <asp:TemplateField HeaderText="Date Stamp"
> >SortExpression="date_stamp">
> > <EditItemTemplate>
> > <asp:CustomValidator ID="Date_Stamp_Update_Validator"
> >runat="server"
> > ControlToValidate="Date_Stamp_Update_Txt"
> > OnServerValidate="Date_Stamp_Update_Txt_Validate"
> > ValidateEmptyText="true"
> > Display="Static"
> > SetFocusOnError="true"
> > ErrorMessage="Must be YYYY-MM-DD!" ></asp:CustomValidator>
> > <asp:TextBox ID="Date_Stamp_Update_Txt"

> runat="server"
> >Text='<%# Bind("date_stamp") %>'
> > BorderStyle="Ridge" BackColor="LightYellow"
> > MaxLength="10" Width="65px"></asp:TextBox>
> > </EditItemTemplate>
> > <ItemTemplate>
> > <asp:Label ID="Date_Stamp_Label" runat="server"
> >Text='<%# Bind("date_stamp") %>'></asp:Label>
> > </ItemTemplate>
> > <ItemStyle HorizontalAlign="Left" VerticalAlign="Bottom"

> Width="9%"
> >Wrap="True"/>
> > <HeaderStyle VerticalAlign="Bottom" />
> > </asp:TemplateField>
> >
> >
> > Protected Sub Date_Stamp_Update_Txt_Validate(ByVal sender As Object,

> ByVal
> >value As ServerValidateEventArgs)
> > ' Must be YYYY-MM-DD Format:
> > If value.Value.ToString.Length = 10 Then
> > Dim dte As DateTime
> > If DateTime.TryParse(value.Value, dte) Then
> > value.IsValid = True
> > Else
> > value.IsValid = False
> > End If
> > Else
> > value.IsValid = False
> > End If
> > End Sub
> >
> >
> >

>
>

 
Reply With Quote
 
doug
Guest
Posts: n/a
 
      14th Mar 2008
I figured it out. I am trying to dynamically modify filtering SQL to add
additional criteria, and added a DataBing to Page_PreRenderComplete - which
isn't working yet, so commenting it out restored errors.

"doug" wrote:

> I added EnableClientScript="false", already had the "onservervalidate=xxx".
> This is the routine that is being fired twice, and each time isPostBack is
> true, and it fails edit setting isValid="false".
>
> Why is this routine fired twice - seemingly one after the other?
>
> ""Steven Cheng"" wrote:
>
> > Hi dmartin,
> >
> > From your description, you found that the custom validator in GridView not
> > work correctly , correct?
> >
> > I've made a simple test on my side and got a customValidator working (with
> > server-side validation) in GridView templateField. I've compared the code
> > and aspx template between my test page and yours. It seems there is no
> > definte difference. I suggest you try the following things:
> >
> > ** explicitly turn off client-side validation(disable client script)
> >
> > ** Try changing your validation handler in codebehind, use some very simple
> > code logic to see whether it work.
> >
> > Here is my test page's aspx and codebehind function for your reference:
> >
> >
> > =======aspx ....==
> > ..............
> > <asp:TemplateField HeaderText="name" SortExpression="name">
> > <EditItemTemplate>
> > <asp:TextBox ID="TextBox1" runat="server" Text='<%#
> > Bind("name") %>'></asp:TextBox>
> > <asp:CustomValidator ID="CustomValidator1"
> > runat="server" ErrorMessage="CustomValidator"
> > ControlToValidate="TextBox1"
> > EnableClientScript="False"
> >
> > onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
> > </EditItemTemplate>
> > <ItemTemplate>
> > <asp:Label ID="Label1" runat="server" Text='<%#
> > Bind("name") %>'></asp:Label>
> > </ItemTemplate>
> > </asp:TemplateField>
> > =============
> >
> >
> > ===========
> > protected void CustomValidator1_ServerValidate(object source,
> > ServerValidateEventArgs args)
> > {
> > if (!args.Value.Contains("Name"))
> > args.IsValid = false;
> > else args.IsValid = true;
> >
> > }
> > =============
> >
> > Sincerely,
> >
> > Steven Cheng
> >
> > Microsoft MSDN Online Support Lead
> >
> >
> > Delighting our customers is our #1 priority. We welcome your comments and
> > suggestions about how we can improve the support we provide to you. Please
> > feel free to let my manager know what you think of the level of service
> > provided. You can send feedback directly to my manager at:
> > (E-Mail Removed).
> >
> > ==================================================
> > Get notification to my posts through email? Please refer to
> > http://msdn.microsoft.com/subscripti...ult.aspx#notif
> > ications.
> >
> > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> > where an initial response from the community or a Microsoft Support
> > Engineer within 1 business day is acceptable. Please note that each follow
> > up response may take approximately 2 business days as the support
> > professional working with you may need further investigation to reach the
> > most efficient resolution. The offering is not appropriate for situations
> > that require urgent, real-time or phone-based interactions or complex
> > project analysis and dump analysis issues. Issues of this nature are best
> > handled working with a dedicated Microsoft Support Engineer by contacting
> > Microsoft Customer Support Services (CSS) at
> > http://msdn.microsoft.com/subscripti...t/default.aspx.
> > ==================================================
> > This posting is provided "AS IS" with no warranties, and confers no rights.
> >
> > --------------------
> > >Thread-Topic: CustomValidator in GridView getting "no message" on errors
> > >thread-index: AciFTXs6Q1/KAGdKQoegfeOqrsqbfg==
> > >X-WBNR-Posting-Host: 171.159.64.10
> > >From: =?Utf-8?B?ZG91Zw==?= <(E-Mail Removed)>
> > >Subject: CustomValidator in GridView getting "no message" on errors
> > >Date: Thu, 13 Mar 2008 14:02:00 -0700

> >
> > >
> > >I have a gridview and have placed customvalidator controls in it.
> > >If I put a break on the sub to do custom validation, run the page, select

> > a
> > >row and press the EDIT button, putting me into Update/Cancel mode, I can

> > edit
> > >the date textbox putting in garbage and press update. It takes the
> > >breakpoint, I step thru, it sets value.isValid=False, and when I exit
> > >routine, same sub fires again (hits same break point) and flow values same
> > >path. Garbage date value still there. If I continue on now, it displays

> > the
> > >gridview, original value of date textbox is back, my error message is not
> > >displayed, but I'm still in Update/Cancel mode,not Edit mode so the update
> > >didn't take place.
> > >
> > > <asp:TemplateField HeaderText="Date Stamp"
> > >SortExpression="date_stamp">
> > > <EditItemTemplate>
> > > <asp:CustomValidator ID="Date_Stamp_Update_Validator"
> > >runat="server"
> > > ControlToValidate="Date_Stamp_Update_Txt"
> > > OnServerValidate="Date_Stamp_Update_Txt_Validate"
> > > ValidateEmptyText="true"
> > > Display="Static"
> > > SetFocusOnError="true"
> > > ErrorMessage="Must be YYYY-MM-DD!" ></asp:CustomValidator>
> > > <asp:TextBox ID="Date_Stamp_Update_Txt"

> > runat="server"
> > >Text='<%# Bind("date_stamp") %>'
> > > BorderStyle="Ridge" BackColor="LightYellow"
> > > MaxLength="10" Width="65px"></asp:TextBox>
> > > </EditItemTemplate>
> > > <ItemTemplate>
> > > <asp:Label ID="Date_Stamp_Label" runat="server"
> > >Text='<%# Bind("date_stamp") %>'></asp:Label>
> > > </ItemTemplate>
> > > <ItemStyle HorizontalAlign="Left" VerticalAlign="Bottom"

> > Width="9%"
> > >Wrap="True"/>
> > > <HeaderStyle VerticalAlign="Bottom" />
> > > </asp:TemplateField>
> > >
> > >
> > > Protected Sub Date_Stamp_Update_Txt_Validate(ByVal sender As Object,

> > ByVal
> > >value As ServerValidateEventArgs)
> > > ' Must be YYYY-MM-DD Format:
> > > If value.Value.ToString.Length = 10 Then
> > > Dim dte As DateTime
> > > If DateTime.TryParse(value.Value, dte) Then
> > > value.IsValid = True
> > > Else
> > > value.IsValid = False
> > > End If
> > > Else
> > > value.IsValid = False
> > > End If
> > > End Sub
> > >
> > >
> > >

> >
> >

 
Reply With Quote
 
Steven Cheng
Guest
Posts: n/a
 
      17th Mar 2008
Thanks for your followup dmartin,

I'm glad that you've figured out the issue.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: =?Utf-8?B?ZG91Zw==?= <(E-Mail Removed)>
>References: <5C052806-8FE6-494B-A58B-(E-Mail Removed)>

<(E-Mail Removed)>
<28D03D9A-0E29-410F-9DC4-(E-Mail Removed)>
>Subject: RE: CustomValidator in GridView getting "no message" on errors
>Date: Fri, 14 Mar 2008 12:29:00 -0700


>
>I figured it out. I am trying to dynamically modify filtering SQL to add
>additional criteria, and added a DataBing to Page_PreRenderComplete -

which
>isn't working yet, so commenting it out restored errors.
>
>"doug" wrote:
>
>> I added EnableClientScript="false", already had the

"onservervalidate=xxx".
>> This is the routine that is being fired twice, and each time isPostBack

is
>> true, and it fails edit setting isValid="false".
>>
>> Why is this routine fired twice - seemingly one after the other?
>>
>> ""Steven Cheng"" wrote:
>>
>> > Hi dmartin,
>> >
>> > From your description, you found that the custom validator in GridView

not
>> > work correctly , correct?
>> >
>> > I've made a simple test on my side and got a customValidator working

(with
>> > server-side validation) in GridView templateField. I've compared the

code
>> > and aspx template between my test page and yours. It seems there is no
>> > definte difference. I suggest you try the following things:
>> >
>> > ** explicitly turn off client-side validation(disable client script)
>> >
>> > ** Try changing your validation handler in codebehind, use some very

simple
>> > code logic to see whether it work.
>> >
>> > Here is my test page's aspx and codebehind function for your reference:
>> >
>> >
>> > =======aspx ....==
>> > ..............
>> > <asp:TemplateField HeaderText="name" SortExpression="name">
>> > <EditItemTemplate>
>> > <asp:TextBox ID="TextBox1" runat="server"

Text='<%#
>> > Bind("name") %>'></asp:TextBox>
>> > <asp:CustomValidator ID="CustomValidator1"
>> > runat="server" ErrorMessage="CustomValidator"
>> > ControlToValidate="TextBox1"
>> > EnableClientScript="False"
>> >
>> >

onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
>> > </EditItemTemplate>
>> > <ItemTemplate>
>> > <asp:Label ID="Label1" runat="server" Text='<%#
>> > Bind("name") %>'></asp:Label>
>> > </ItemTemplate>
>> > </asp:TemplateField>
>> > =============
>> >
>> >
>> > ===========
>> > protected void CustomValidator1_ServerValidate(object source,
>> > ServerValidateEventArgs args)
>> > {
>> > if (!args.Value.Contains("Name"))
>> > args.IsValid = false;
>> > else args.IsValid = true;
>> >
>> > }
>> > =============
>> >
>> > Sincerely,
>> >
>> > Steven Cheng
>> >
>> > Microsoft MSDN Online Support Lead
>> >
>> >
>> > Delighting our customers is our #1 priority. We welcome your comments

and
>> > suggestions about how we can improve the support we provide to you.

Please
>> > feel free to let my manager know what you think of the level of

service
>> > provided. You can send feedback directly to my manager at:
>> > (E-Mail Removed).
>> >
>> > ==================================================
>> > Get notification to my posts through email? Please refer to
>> >

http://msdn.microsoft.com/subscripti...ult.aspx#notif
>> > ications.
>> >
>> > Note: The MSDN Managed Newsgroup support offering is for non-urgent

issues
>> > where an initial response from the community or a Microsoft Support
>> > Engineer within 1 business day is acceptable. Please note that each

follow
>> > up response may take approximately 2 business days as the support
>> > professional working with you may need further investigation to reach

the
>> > most efficient resolution. The offering is not appropriate for

situations
>> > that require urgent, real-time or phone-based interactions or complex
>> > project analysis and dump analysis issues. Issues of this nature are

best
>> > handled working with a dedicated Microsoft Support Engineer by

contacting
>> > Microsoft Customer Support Services (CSS) at
>> > http://msdn.microsoft.com/subscripti...t/default.aspx.
>> > ==================================================
>> > This posting is provided "AS IS" with no warranties, and confers no

rights.
>> >
>> > --------------------
>> > >Thread-Topic: CustomValidator in GridView getting "no message" on

errors
>> > >thread-index: AciFTXs6Q1/KAGdKQoegfeOqrsqbfg==
>> > >X-WBNR-Posting-Host: 171.159.64.10
>> > >From: =?Utf-8?B?ZG91Zw==?= <(E-Mail Removed)>
>> > >Subject: CustomValidator in GridView getting "no message" on errors
>> > >Date: Thu, 13 Mar 2008 14:02:00 -0700
>> >
>> > >
>> > >I have a gridview and have placed customvalidator controls in it.
>> > >If I put a break on the sub to do custom validation, run the page,

select
>> > a
>> > >row and press the EDIT button, putting me into Update/Cancel mode, I

can
>> > edit
>> > >the date textbox putting in garbage and press update. It takes the
>> > >breakpoint, I step thru, it sets value.isValid=False, and when I exit
>> > >routine, same sub fires again (hits same break point) and flow values

same
>> > >path. Garbage date value still there. If I continue on now, it

displays
>> > the
>> > >gridview, original value of date textbox is back, my error message is

not
>> > >displayed, but I'm still in Update/Cancel mode,not Edit mode so the

update
>> > >didn't take place.
>> > >
>> > > <asp:TemplateField HeaderText="Date Stamp"
>> > >SortExpression="date_stamp">
>> > > <EditItemTemplate>
>> > > <asp:CustomValidator ID="Date_Stamp_Update_Validator"
>> > >runat="server"
>> > > ControlToValidate="Date_Stamp_Update_Txt"
>> > > OnServerValidate="Date_Stamp_Update_Txt_Validate"
>> > > ValidateEmptyText="true"
>> > > Display="Static"
>> > > SetFocusOnError="true"
>> > > ErrorMessage="Must be YYYY-MM-DD!" ></asp:CustomValidator>
>> > > <asp:TextBox ID="Date_Stamp_Update_Txt"
>> > runat="server"
>> > >Text='<%# Bind("date_stamp") %>'
>> > > BorderStyle="Ridge" BackColor="LightYellow"
>> > > MaxLength="10" Width="65px"></asp:TextBox>
>> > > </EditItemTemplate>
>> > > <ItemTemplate>
>> > > <asp:Label ID="Date_Stamp_Label"

runat="server"
>> > >Text='<%# Bind("date_stamp") %>'></asp:Label>
>> > > </ItemTemplate>
>> > > <ItemStyle HorizontalAlign="Left" VerticalAlign="Bottom"
>> > Width="9%"
>> > >Wrap="True"/>
>> > > <HeaderStyle VerticalAlign="Bottom" />
>> > > </asp:TemplateField>
>> > >
>> > >
>> > > Protected Sub Date_Stamp_Update_Txt_Validate(ByVal sender As Object,
>> > ByVal
>> > >value As ServerValidateEventArgs)
>> > > ' Must be YYYY-MM-DD Format:
>> > > If value.Value.ToString.Length = 10 Then
>> > > Dim dte As DateTime
>> > > If DateTime.TryParse(value.Value, dte) Then
>> > > value.IsValid = True
>> > > Else
>> > > value.IsValid = False
>> > > End If
>> > > Else
>> > > value.IsValid = False
>> > > End If
>> > > End Sub
>> > >
>> > >
>> > >
>> >
>> >

>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Send/Receive error message, but no "errors" are listed Don Windows Vista Mail 7 10th Sep 2009 12:29 AM
website displayed blank with "Done, but errors on page" message =?Utf-8?B?WWlu?= Windows XP Internet Explorer 2 28th Oct 2005 02:30 AM
OL 2003: Contacts folder adds/changes always get "errors have been detected ..." message I live on Quicken and Outlook Microsoft Outlook 3 18th Feb 2005 01:43 PM
When I try to open Control Panel\"Add/remove programs", I get the message shown in the subject line of this message posting. When I then get in "Add/remove programs", I cannot uncheck box next to "Message Queuing" in Con =?Utf-8?B?cGJhZXJ3YWxk?= Windows XP Help 2 14th Jan 2004 03:11 PM
Manual "Windows Update" produces "ActiveX/active scripting" error message even with "LOW" security level setting in "Trusted" Zone Ray2 Windows XP Help 1 14th Nov 2003 06:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:10 AM.