How to inherit from RadTextBox?

3 posts, 0 answers
  1. Zdeněk
    Zdeněk avatar
    27 posts
    Member since:
    May 2007

    Posted 15 Feb 2010 Link to this post

    I want to extend RadTextBox by implementing RequiredFieldValidator. I did simillar functionality with asp:textbox :

    Public Class MyTextBox 
            Inherits WebControls.TextBox 
     
            Private req As New RequiredFieldValidator 
     
            Protected Overrides Sub OnInit(ByVal e As EventArgs) 
                req.ControlToValidate = Me.ID 
                req.Display = ValidatorDisplay.Dynamic 
                req.ErrorMessage = "Please fill marked field(-s)" 
                req.Text = "*" 
                req.EnableClientScript = True 
                Controls.Add(req) 
            End Sub 
     
            Protected Overrides Sub Render(ByVal w As HtmlTextWriter) 
                MyBase.Render(w) 
                req.RenderControl(w) 
            End Sub 
     
     End Class 

    When I want to inherit from RadTextBox (at line 2: Inherits Telerik.Web.UI.RadTextBox), code stops working with weird error:

    Unable to find control id 'txtTest' referenced by the 'ControlToValidate' property of ''.


    What I'm doing wrong? Thank you for your help!

    Zdenek

  2. Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 17 Feb 2010 Link to this post

    Hi Zdenek,

    I am afraid that inheriting from RadTextBox in that way is not supported due to limitation that prevents the Validator from getting the correct ID. You can try inheriting from WebControl instead and putting the RadTextbox and its validator inside it.

    Best wishes,
    Pavel
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Zdeněk
    Zdeněk avatar
    27 posts
    Member since:
    May 2007

    Posted 17 Feb 2010 Link to this post

    Thank you. Most needed functionality will bring me RadInputManager.
Back to Top