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. Validation Control

Validation Control

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netvisual-studioquestion
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.
  • A Offline
    A Offline
    Armando_Ramirez
    wrote on last edited by
    #1

    Hi there I'm working whit Visual Studio 2005 developing an ASP.NET 2.0 WebPage I have a DropDownList Control with 2 options to select. I want to generate a validation message according to the selection made in the DropDownList Control. Any ideas??? THANX ¡¡

    A 1 Reply Last reply
    0
    • A Armando_Ramirez

      Hi there I'm working whit Visual Studio 2005 developing an ASP.NET 2.0 WebPage I have a DropDownList Control with 2 options to select. I want to generate a validation message according to the selection made in the DropDownList Control. Any ideas??? THANX ¡¡

      A Offline
      A Offline
      Are Jay
      wrote on last edited by
      #2

      Server-side or client-side?

      A 1 Reply Last reply
      0
      • A Are Jay

        Server-side or client-side?

        A Offline
        A Offline
        Armando_Ramirez
        wrote on last edited by
        #3

        Server-side please

        A 1 Reply Last reply
        0
        • A Armando_Ramirez

          Server-side please

          A Offline
          A Offline
          Are Jay
          wrote on last edited by
          #4

          Sub DropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DropDownList.SelectedIndexChanged Dim script As String = "" Dim ctrl As DropDownList = CType(sender, DropDownList) If ctrl.SelectedValue = "something" Then ' Some Kinda Validation occurs script = "alert('This is what was selected: " & ctrl.SelectedValue & "');" Else ' Some Kinda Validation occurs script = "alert('This is what was selected: " & ctrl.SelectedValue & "');" End If Me.ClientScript.RegisterClientScriptBlock(Me.GetType, "Alert", script, True) End Sub Is this what you had in mind?

          G 1 Reply Last reply
          0
          • A Are Jay

            Sub DropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DropDownList.SelectedIndexChanged Dim script As String = "" Dim ctrl As DropDownList = CType(sender, DropDownList) If ctrl.SelectedValue = "something" Then ' Some Kinda Validation occurs script = "alert('This is what was selected: " & ctrl.SelectedValue & "');" Else ' Some Kinda Validation occurs script = "alert('This is what was selected: " & ctrl.SelectedValue & "');" End If Me.ClientScript.RegisterClientScriptBlock(Me.GetType, "Alert", script, True) End Sub Is this what you had in mind?

            G Offline
            G Offline
            Grapes R Fun
            wrote on last edited by
            #5

            just an fyi- make sure you provide the html control name when incorporating it within the script string... server controls sometimes take a different name once the result page is sent from the server back to the client. Now, why would anyone be interested in server-side validation? Postbacks are very inefficient! To validate without making round trips to the server, look into using validation controls such as RegularExpression or CompareValidator. Nila Fridley

            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