ASP Hyperlink control using href="#" and validation
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 p开发者_StackOverflow中文版age?
Thanks
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>
have you tryed using a linkbutton? you can set onclientclick="return false;" to prevent a postback and it should cause the validation
You could add EnableClientScript="true"
to your validation control. By doing this the validation will be performed in javascript before a postback occurs.
精彩评论