This is a migrated thread and some comments may be shown as answers.

How to inherit from RadTextBox?

2 Answers 133 Views
Input
This is a migrated thread and some comments may be shown as answers.
Zdeněk
Top achievements
Rank 1
Zdeněk asked on 15 Feb 2010, 08:15 PM
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 Answers, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 17 Feb 2010, 11:29 AM
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.
0
Zdeněk
Top achievements
Rank 1
answered on 17 Feb 2010, 01:33 PM
Thank you. Most needed functionality will bring me RadInputManager.
Tags
Input
Asked by
Zdeněk
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Zdeněk
Top achievements
Rank 1
Share this question
or