Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. RFV. Problem with ID. I think ...

RFV. Problem with ID. I think ...

Scheduled Pinned Locked Moved ASP.NET
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shapper
    wrote on last edited by
    #1

    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

    I G 2 Replies Last reply
    0
    • 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

      I Offline
      I Offline
      indianet
      wrote on last edited by
      #2

      You have not set the ID for the TextBox Control

      S 1 Reply Last reply
      0
      • I indianet

        You have not set the ID for the TextBox Control

        S Offline
        S Offline
        shapper
        wrote on last edited by
        #3

        Hi, I am lost but does not "Implements INamingContainer" does that? Thanks, Miguel

        1 Reply Last reply
        0
        • 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

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Set the ControlToValidate property after you have added the text box to the page.

          --- b { font-weight: normal; }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups