RFV. Problem with ID. I think ...

S

shapper

Hello,

I am creating a custom control which uses TextBoxes and Required field
validator. I am using INamingContainer in my custom control.

When I use the control in a page I get an error:

"The ControlToValidate property of 'rfvEmail' cannot be blank. "

I have no idea why I am getting this error. It is like I did not
referenced the rfvEmail.ControlToValidate. But I did.

I tried everything I could think off but had no luck.

Could somebody help me out?

Here is my code:

Public Class MyControl
Inherits WebControl
Implements INamingContainer

Private WithEvents tbEmail As New WebControls.TextBox
Private WithEvents rfvEmail As New
WebControls.RequiredFieldValidator

Private Sub tbEmail_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tbEmail.Init
tbEmail.Width = Unit.Pixel(200)
End Sub

Private Sub rfvEmail_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles rfvEmail.Init
.ControlToValidate = tbEmail.ID ' ???????? ERROR ?????????
.Display = ValidatorDisplay.Dynamic
.ErrorMessage = "Required Field"
End Sub

Protected Overrides Sub CreateChildControls()

MyBase.Controls.Add(tbEmail)
MyBase.Controls.Add(rfvEmail)

MyBase.CreateChildControls()
Me.ChildControlsCreated = True

End Sub

End Class

Thank You Very Much,

Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top