ASP.NET Button ValidationGroup OnClientClick Not Working

This post describes how to fix OnClientClick validation on an ASP.NET page.

Problem

You've added OnClientClick to a button which contains Page_ClientValidate:

OnClientClick="Page_ClientValidate(''); if (!Page_IsValid) return false; return confirm('Are you sure?');"

But it is not working when you press the button.

Cause

This can be caused because there are multiple validation groups on the page.

Resolution

To resolve the issue, specify the ValidationGroup in the Page_ClientValidate method:

OnClientClick="Page_ClientValidate('validationGroup'); if (!Page_IsValid) return false; return confirm('Are you sure?');"

Comments

Popular posts from this blog

LG TV This app will now restart to free up more memory

LG TV Clear All Browsing History Data

Excel Import CSV not using "Use First Row as Headers"