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. Adding RequiredFieldValidtors programmatically

Adding RequiredFieldValidtors programmatically

Scheduled Pinned Locked Moved ASP.NET
helpquestion
3 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.
  • M Offline
    M Offline
    meeram395
    wrote on last edited by
    #1

    I am creating a couple of textboxes and dropdownlists dynamically. I need to put RFV for all of them. Since the rfv id will be different for each control, how will I generate them and make them fire if the values are not entered by the user. I tried adding the following: RequiredFieldValidator rfv1 = new RequiredFieldValidator(); rfv1.ControlToValidate = fieldTextBox.Id; But this is not firing? ANy help in this regard please? Thanks,

    Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

    A S 2 Replies Last reply
    0
    • M meeram395

      I am creating a couple of textboxes and dropdownlists dynamically. I need to put RFV for all of them. Since the rfv id will be different for each control, how will I generate them and make them fire if the values are not entered by the user. I tried adding the following: RequiredFieldValidator rfv1 = new RequiredFieldValidator(); rfv1.ControlToValidate = fieldTextBox.Id; But this is not firing? ANy help in this regard please? Thanks,

      Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      meeram395 wrote:

      RequiredFieldValidator rfv1 = new RequiredFieldValidator(); rfv1.ControlToValidate = fieldTextBox.Id; But this is not firing? ANy help in this regard please?

      I have write this on Page_Load() RequiredFieldValidator _re = new RequiredFieldValidator(); _re.ID = "test"; _re.ControlToValidate = txtRoll.ID; _re.ErrorMessage = "This is a error Message"; form1.Controls.Add(_re); and working fine ;)

      cheers, Abhijit CodeProject MVP My Blog :Abhijit's World of .Net

      1 Reply Last reply
      0
      • M meeram395

        I am creating a couple of textboxes and dropdownlists dynamically. I need to put RFV for all of them. Since the rfv id will be different for each control, how will I generate them and make them fire if the values are not entered by the user. I tried adding the following: RequiredFieldValidator rfv1 = new RequiredFieldValidator(); rfv1.ControlToValidate = fieldTextBox.Id; But this is not firing? ANy help in this regard please? Thanks,

        Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

        S Offline
        S Offline
        SachinKumar M
        wrote on last edited by
        #3

        give some error message for your required field Validator like rfv1.ErrorMessage ="Some Message"

        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