locked
ValidatorCalloutExtender does not work in this very simple aspx file RRS feed

  • Question

  • User1366894300 posted

    When I leave the textbox txtFirstName empty and click the button only the text "Enter a name" from RequiredFieldValidator is displayed.So the ValidatorCalloutExtender does not have any effect on the displayed error message.

    I use the AjaxControlToolkit for .NET 4.5 and I use VS 2013 Ultimate

    In this some kind of bug it's a very basic page.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Modul_3.WebForm1" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>

            <asp:Label ID="Label1" runat="server" Text="FirstName" />
            <asp:TextBox ID="txtFirstName" runat="server" />
              
            <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="txtFirstName" ErrorMessage="Enter a name" Display="Dynamic">
            </asp:RequiredFieldValidator>

            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" Width="350px"
                TargetControlID="rfvFirstName">
            </asp:ValidatorCalloutExtender>

            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        </form>
    </body>
    </html>

    //Tony

    Saturday, April 12, 2014 1:37 PM

Answers

  • User1366894300 posted

    I found the problem I had to do this. This is special for .net 4.5

    <appSettings>
        <add key="ValidationSettings:UnobtrusiveValidationMode" value="None">
      </appSettings>

    Thanks any way

    //tony

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 13, 2014 5:25 PM
  • User724169276 posted

    glad you found the solution by yourself.unobtructive validation is sometimes the solution for strange behaviour from validation controls .. Laughing

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 13, 2014 9:39 PM

All replies

  • User724169276 posted

    Hello Tojo,

    Use display none for required field validator.

     <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
    
            <asp:Label ID="Label1" runat="server" Text="FirstName" />
            <asp:TextBox ID="txtFirstName" runat="server" />
              
            <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="txtFirstName" ErrorMessage="Enter a name" Display="None">
            </asp:RequiredFieldValidator>
    
            <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" Width="350px"
                TargetControlID="rfvFirstName">
            </asp:ValidatorCalloutExtender>
    
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

    Sunday, April 13, 2014 12:31 PM
  • User1366894300 posted

    No it's the same not working

    //Tony

    Sunday, April 13, 2014 1:43 PM
  • User724169276 posted

    it should work .. ok try to set text property of required field validator .. (Text="*")

    Sunday, April 13, 2014 1:45 PM
  • User1366894300 posted

    I found the problem I had to do this. This is special for .net 4.5

    <appSettings>
        <add key="ValidationSettings:UnobtrusiveValidationMode" value="None">
      </appSettings>

    Thanks any way

    //tony

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 13, 2014 5:25 PM
  • User724169276 posted

    glad you found the solution by yourself.unobtructive validation is sometimes the solution for strange behaviour from validation controls .. Laughing

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, April 13, 2014 9:39 PM