Asp.net require field validator stops click event

qasimidl 106 Reputation points
2023-03-09T14:20:24.5666667+00:00

Hi,

i have designed web part in SharePoint 2019,

problem:

as i place required field validator on text box, so it stops button click event. (asp.net button click event)

as i remove require field validator, button click events works.

Kindly suggest, what to do to solve it, once data is provide so require validator should let button to play its role.

Thanks

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,288 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,686 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 31,681 Reputation points Microsoft Vendor
    2023-03-10T02:02:37.19+00:00

    Hi @qasimidl

    You can refer to following code to stop click event without data filled in text

    function submitform()
    {
        if (!Page_IsValid) {
            return false;
        }
        return sendHPCIMsg();
    }
    
    
    <asp:Button ID="formPost" text="Submit" class="btn btn-default" runat="server" CausesValidation="true" OnClientClick="return submitform();" />
    
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful