locked
Page_ClientValidate is undefined before postback but present after postback RRS feed

  • Question

  • On my server, Page_ClientValidate javascript function is undefined when user comes to the page for the first time, but after the postback it is there and defined. The problem is that the forms won't get validated on the client side and will always be submited to the server.

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ValidatorTest.ascx.cs" Inherits="ValidatorTest" %>
    <asp:textbox runat="server" ID="txtTest"  />
    <asp:RequiredFieldValidator runat="server" ControlToValidate="txtTest" Display="Static" ErrorMessage="*" SetFocusOnError="true"  ValidationGroup="VG"/>
    <asp:LinkButton runat="server" ID="btnSubmit" Text="Submit" OnClick="btnSubmit_Click" ValidationGroup="VG" />
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class ValidatorTest : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
    
        }
    }

    This will get submited even if the txtTest is empty but after the postback it won't.




    Tuesday, January 2, 2018 12:44 PM

All replies

  • Hi Great_R,

    Thank you for posting here.

    According to your question is more related to ASP.NET, you could post a new thread in ASP.NET forum fro suitable support.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework, including Managed Extensibility Framework (MEF), Charting Controls, CardSpace, Windows Identity Foundation (WIF), Point of Sale (POS), Transactions. 

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 3, 2018 6:36 AM