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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Asp.net validation

Asp.net validation

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netcomalgorithmstutorial
5 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.
  • N Offline
    N Offline
    Naveed Kamboh
    wrote on last edited by
    #1

    Hi Friends, My Scenario is I've got two controls TextBox and DropDownlist. I want to validate these as If Textbox is empty then you must select a valued from dropdown list , if text box is not empty then its up to user weather he/she wants to select a value from dropdownlist or not. Can I validate using Validation controls? If yes then how ? Any example or source code will be appreciated.

    Naveed Kamboh Complexity kills, Write easy code for your self. Cash-time

    L 1 Reply Last reply
    0
    • N Naveed Kamboh

      Hi Friends, My Scenario is I've got two controls TextBox and DropDownlist. I want to validate these as If Textbox is empty then you must select a valued from dropdown list , if text box is not empty then its up to user weather he/she wants to select a value from dropdownlist or not. Can I validate using Validation controls? If yes then how ? Any example or source code will be appreciated.

      Naveed Kamboh Complexity kills, Write easy code for your self. Cash-time

      L Offline
      L Offline
      Laddie
      wrote on last edited by
      #2

      Just a quick question. Where is the place you need to check this. I mean on a button click or something ?

      Thanks Laddie Kindly rate if the answer was helpful

      N 1 Reply Last reply
      0
      • L Laddie

        Just a quick question. Where is the place you need to check this. I mean on a button click or something ?

        Thanks Laddie Kindly rate if the answer was helpful

        N Offline
        N Offline
        Naveed Kamboh
        wrote on last edited by
        #3

        Yes on an image button click. I am after client side validation!

        Naveed Kamboh Complexity kills, Write easy code for your self. Punjabi stuff

        E L 2 Replies Last reply
        0
        • N Naveed Kamboh

          Yes on an image button click. I am after client side validation!

          Naveed Kamboh Complexity kills, Write easy code for your self. Punjabi stuff

          E Offline
          E Offline
          eyeseetee
          wrote on last edited by
          #4

          use this: runat="server" ErrorMessage="Required Field" ControlToValidate="textbox">

          1 Reply Last reply
          0
          • N Naveed Kamboh

            Yes on an image button click. I am after client side validation!

            Naveed Kamboh Complexity kills, Write easy code for your self. Punjabi stuff

            L Offline
            L Offline
            Laddie
            wrote on last edited by
            #5

            Ok then create a javascript to validate your control. if say function validate() { //Check if the text box value is blank if(document.getElementById("txtBox1").Value.length == 0) { //If yes check if the value of listbox is null if(documen.getElementById("listbox").Value == null) { alert("You have to select a value"); return false; } } } Now in the OnClientClick property of the image button give this funcion name You probably will not be able to achieve this using validation controls becuase they can be used against only one control.

            Thanks Laddie Kindly rate if the answer was helpful

            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