Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Tue, 1 Jul 2008 17:02:20 -0400,    group: microsoft.public.dotnet.framework.aspnet.webcontrols        back       


Custom Validator and ServerValidateEventArgs   
Having a problem with ServerValidateEventArgs value when a Custom Validator 
is fired.  The method that is executed is very simple.  Evertime it is fired 
the value of ServerValidateEventArgs is always blank while debugging (the 
textbox does have a value in it).  The code is from a web control that is 
inside another web control (aspx page that has control on it, and that 
control contains the control that doesn't validate).  Both controls are 
using MultiViews if that matters.  If I put this control and its code on a 
simple aspx page (one control on an aspx page) it works fine. Any ideas? 
Thanks for reading.

protected void ValidateSecurityCode(object sender, ServerValidateEventArgs 
e)
 {
  if (_required)
  {
   //check to see if it has a value or not
   e.IsValid = !string.IsNullOrEmpty(e.Value);
  }
  else
  {
   e.IsValid = true;
  }
 }

<asp:TextBox runat="server" ID="CodeTextBox" ValidationGroup="PaymentValues" 
EnableViewState="false"/>
<asp:CustomValidator runat="server" ID="CodeCustomValidator" 
OnServerValidate="ValidateSecurityCode"
  ControlToValidate="CodeTextBox" meta:resourceKey="CodeTextBoxResource"
  ValidateEmptyText="true" CssClass="formValidationErrorInline" 
ForeColor="#db4242"
  ValidationGroup="PaymentValues" />
date: Tue, 1 Jul 2008 17:02:20 -0400   author:   zeplynne

Re: Custom Validator and ServerValidateEventArgs   
On Jul 2, 3:02 am, "zeplynne"  wrote:
> Having a problem with ServerValidateEventArgs value when a Custom Validator
> is fired.  The method that is executed is very simple.  Evertime it is fired
> the value of ServerValidateEventArgs is always blank while debugging (the
> textbox does have a value in it).  The code is from a web control that is
> inside another web control (aspx page that has control on it, and that
> control contains the control that doesn't validate).  Both controls are
> using MultiViews if that matters.  If I put this control and its code on a
> simple aspx page (one control on an aspx page) it works fine. Any ideas?
> Thanks for reading.
>
> protected void ValidateSecurityCode(object sender, ServerValidateEventArgs
> e)
>  {
>   if (_required)
>   {
>    //check to see if it has a value or not
>    e.IsValid = !string.IsNullOrEmpty(e.Value);
>   }
>   else
>   {
>    e.IsValid = true;
>   }
>  }
>
> <asp:TextBox runat="server" ID="CodeTextBox" ValidationGroup="PaymentValues"
> EnableViewState="false"/>
> <asp:CustomValidator runat="server" ID="CodeCustomValidator"
> OnServerValidate="ValidateSecurityCode"
>   ControlToValidate="CodeTextBox" meta:resourceKey="CodeTextBoxResource"
>   ValidateEmptyText="true" CssClass="formValidationErrorInline"
> ForeColor="#db4242"
>   ValidationGroup="PaymentValues" />


Hi zeplynne

Not sure about your particular case, but MultiView has a ViewState
problem which may cause you this: http://is.gd/KhU

Tanzim Saqib
http://www.TanzimSaqib.com
date: Wed, 2 Jul 2008 02:17:28 -0700 (PDT)   author:   Tanzim Saqib

Re: Custom Validator and ServerValidateEventArgs   
Hi

> [...]
> textbox does have a value in it).  The code is from a web control that is 
> inside another web control (aspx page that has control on it, and that 
> control contains the control that doesn't validate).  Both controls are 
> using MultiViews if that matters.  If I put this control and its code on a 
> simple aspx page (one control on an aspx page) it works fine. Any ideas? 
> Thanks for reading.
What kind of webcontrol are those both?
Does both implement INamingContainer in case of ensure unique IDs?

-- 
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
date: Mon, 7 Jul 2008 10:31:50 +0200   author:   Peter Bucher [MVP]

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us