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: Thu, 3 Jul 2008 03:41:02 -0700,    group: microsoft.public.dotnet.framework.aspnet.webcontrols        back       


CustomValidator inside a DetailsView   
Hi,

I have, in a webform, a DetailView with 8 fields, 4 of them are required and 
I'm using a RequiredValidator with no problems, the other 4 must be all empty 
or all filled (cannot be some empty and other filled). To validate this I'm 
using a CustomValidator but with no sucess:
- the event defined in the attribute OnServerValidate="OnValidateOverride" 
is not triggered;
- the clientside function defined in the attribute 
ClientValidationFunction="GradeValidate" is triggered but in javascript i 
can´t reach the controls inside DetailsView template fields;

if the textboxs and Validators are outside de Detailsview it works fine.
Can someone give me a clue?
Thanks in advance,

Example:
	aspx:
		<script type="text/javascript" language="javascript">
			function TestValidate(source, args)
			{
				var obj = document.getElementById("<%=TestDetailsView.ClientID%>");
				..........
				//the TestDetailsView is reached but the controls inside are not
			}
		</script>

		...............

		<asp:TextBox ID="TextBox1" runat="server"/>
		<asp:TextBox ID="TextBox2" runat="server"/>
		<asp:CustomValidator ID="CustomValidatorTeste1" runat="server" 
OnServerValidate="OnValidateOverride" ClientValidationFunction="TesteValidate"
			ControlToValidate="TextBox1"  ValidationGroup="testeGroup" 
ErrorMessage="Obrigatório preencher os restantes campos de override"/>
		<asp:CustomValidator ID="CustomValidatorTeste2" runat="server" 
OnServerValidate="OnValidateOverride" ClientValidationFunction="TesteValidate"
			ControlToValidate="TextBox2"  ValidationGroup="testeGroup" 
ErrorMessage="Obrigatório preencher os restantes campos de override"/>
		<asp:LinkButton ID="InsertBtn" runat="server" Text="Testar" 
ValidationGroup="testeGroup"  />

	codebehind:
		public void OnValidateOverride(object sender, ServerValidateEventArgs e)
		{
			e.IsValid = ((this.TextBox1.Text != string.Empty && this.TextBox2.Text != 
string.Empty) ||
				(this.TextBox1.Text == string.Empty && this.TextBox2.Text == 
string.Empty));
		}


-- 
Paulo
date: Thu, 3 Jul 2008 03:41:02 -0700   author:   Paulo Costa

Google
 
Web ureader.com


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