Reputation: 1089
I'm having an issue using the asp hyperlink control and the "#" href value. I don't want the link to navigate away from the current page or reload it but I want the link to cause validation to happen to a specific validation group.
The following line doesn't trigger validation.
<asp:HyperLink id="next" runat="server" CausesValidation="true" ValidationGroup="SideRifStepOne" href="#">Next Step</asp:HyperLink>
If I use the same attributes for the validation works but the page is reloaded. Any suggestions for triggering validation without reloading the page?
Thanks
Upvotes: 2
Views: 4202
Reputation: 82933
Another solution would be calling Page_ClientValidate() manually:
<asp:HyperLink id="next" runat="server" href="javascript:doValidate()">Next Step</asp:HyperLink>
<script type="text/javascript">
function doValidate()
{
Page_ClientValidate();
}
</script>
Upvotes: 3
Reputation: 39695
You could add EnableClientScript="true"
to your validation control. By doing this the validation will be performed in javascript before a postback occurs.
Upvotes: 0
Reputation: 2487
have you tryed using a linkbutton? you can set onclientclick="return false;" to prevent a postback and it should cause the validation
Upvotes: 1