Error using custom validation control

When I run the code below I get the error :  Unknown server tag 'custom:LengthValidator'.
I have tried adding Assembly = "myProject" to the Register tag and that didn't hep.  I'm using Visual Studio 2010 and ASP.Net 4.0.  This is an example from ASP.Net 4 Unleashed.  

ShowLengthValidator.aspx is below:  

<%@ Page Language="VB" %>
<%@ Register TagPrefix="custom" Namespace="myControls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Show Length Validator</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    <asp:Label
        id="lblComments"
        Text="Comments:"
        AssociatedControlID="txtComments"
        Runat="server" />
    <br />
    <asp:TextBox
        id="txtComments"
        TextMode="MultiLine"
        Columns="30"
        Rows="2"
        Runat="server" />
    <custom:LengthValidator
        id="valComments"
        ControlToValidate="txtComments"
        Text="(Must be less than 10 characters)"
        MaximumLength="10"
        Runat="server" />
   
    <br /><br />
   
    <asp:Button
        id="btnSubmit"
        Text="Submit"
        Runat="server" />
   
    </div>
    </form>
</body>
</html>

LengthValidator.vb code is below:

Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace myControls

    ''' <summary>
    ''' Validates the length of an input field
    ''' </summary>
    Public Class LengthValidator
        Inherits BaseValidator

        Dim _maximumLength As Integer = 0

        Public Property MaximumLength() As Integer
            Get
                Return _maximumLength
            End Get
            Set(ByVal Value As Integer)
                _maximumLength = value
            End Set
        End Property

        Protected Overrides Function EvaluateIsValid() As Boolean
            Dim value As String = Me.GetControlValidationValue(Me.ControlToValidate)
            If value.Length > _maximumLength Then
                Return False
            Else
                Return True
            End If
        End Function
    End Class
End Namespace
timothyrmyersAsked:
Who is Participating?
 
lenordisteCommented:
did you try adding it to your web.config file ?
<configuration>
  <system.web>
    <pages>
      <controls>
        <add tagPrefix="custom" namespace="myControls"/>
      </controls>
    </pages>
  </system.web>
</configuration>

Open in new window

0
 
Amandeep Singh BhullarCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 
timothyrmyersAuthor Commented:
Please close this question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.