The custom validation control works fine for the oddball cases. NOT
using the validation controls because they don't always fill the need is
very short sited.
Since I don't know exactly what you are coding, I won't go so far as to
say that I could do anything you are doing the hard way (imo) with a
custom validation control. But, I'm pretty darn sure I could. Which
would save me time in the long run because I could use the regular
validation controls for the things that are common.
-----Original Message-----
From: Mark Rae [MVP] [mailto:ma**@mar kNOSPAMrae.net]
Posted At: Monday, November 05, 2007 5:51 PM
Posted To: microsoft.publi c.dotnet.framew ork.aspnet
Conversation: Sharing a Validator
Subject: Re: Sharing a Validator
"Nathan Sokalski" <nj********@hot mail.comwrote in message
news:eQ******** ******@TK2MSFTN GP05.phx.gbl...
[cross-posting removed]
a validator can only be in one validationgroup
This is one of the reasons that I never go anywhere near the validation
controls...
They're fine for basic stuff, but simply aren't flexible enough for more
complex validation.
For this, I'd just have one JavaScript function which accepts a
parameter to
indicate whether the record is to be inserted or updated...
<script type="text/javascript">
function validateForm(ps trMode)
{
// common validation
if (pstrMode == 'New')
{
// extra validation for inserts
}
}
</script>
<asp:Button ID="cmdAdd" runat="server" Text="Add"
OnCommand="Save _Command"
CommandArgument ="Add" OnClientClick=" return validateForm('N ew');" />
<asp:Button ID="cmdEdit" runat="server" Text="Edit"
OnCommand="Save _Command"
CommandArgument ="Edit" OnClientClick=" return validateForm('E dit');" />
--
Mark Rae
ASP.NET MVP
http://www.markrae.net