Having problems with my validation

g_r_a_robinson

Regular
Joined
Jan 13, 2004
Messages
71
Hi all.

I have a page that requires a lot of validation, I'm mainly using the requiredfieldvalidator.

<code>
<asp:requiredfieldvalidator id="RequiredFieldValidator4" runat="server" display="dynamic" errormessage="Name is a required field" controlToValidate="Names">*</asp:requiredfieldvalidator>
</code>

I also have a user control that contains links to other pages. My problem is that if I decide I don't want to actually submit my page but rather click on one my links I get stopped by the validation for the page. Is there anyway I can insulate my menu control from the main page so that I can still move away from it if I need to. I understand that some might say that defeats the whole purpose of the validation in the first place, but I only need it to respond to the add entry button not to everything else on the page.

Thanks
 
Thanks for that it gave me the idea below, but its still not there

OK this is what I did.

I set all disasbled all of my validation like so:

<code>
<asp:requiredfieldvalidator id="Requiredfieldvalidator12" runat="server" display="dynamic" errormessage="Password is a required field" controlToValidate="Passwords" Enabled="False">*</asp:requiredfieldvalidator></TD>
</code>

IE disabled them all to false.

I then used the 'OnClick' method of my button like so:

<code>
<asp:button id="AddUser" onclick="Enable_Validation" runat="server" Text="Add User"></asp:button>
</code>

and my sub Enable_Validation

<code>
public void Enable_Validation(Object sender, EventArgs e)
{
ValidationSummary1.Enabled = true;
RequiredFieldValidator4.Enabled = true;
RequiredFieldValidator1.Enabled = true;
RegularExpressionValidator1.Enabled = true;
EmailUniqueCustomValidator.Enabled = true;
RequiredFieldValidator2.Enabled = true;
Requiredfieldvalidator3.Enabled = true;
Requiredfieldvalidator9.Enabled = true;
Requiredfieldvalidator10.Enabled = true;
Requiredfieldvalidator11.Enabled = true;
Requiredfieldvalidator12.Enabled = true;

}
</code>

It works, but my problem is that its enabling the controls and then straight away submitting the info. In ohter words it bypasses the validation on the first add_entry click/ On the second I see the validation kick in, but by then its too late because the data has already been submitted. Anyone know a better way?
 
Back
Top