RFV. Problem with ID. I think ...
-
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
-
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
-
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