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. Disable controls and validators client-side

Disable controls and validators client-side

Scheduled Pinned Locked Moved ASP.NET
asp-nethelpcsharpjavascriptdatabase
1 Posts 1 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.
  • D Offline
    D Offline
    dabs
    wrote on last edited by
    #1

    Hi, I have a page that is pretty complex, i.e. it has a table with lots of controls, everything generated from data in a database. Each row contains among others a DropDownList, and when certain items are selected in that dropdownlist, the rest of that row should be disabled. The rest of that row contains text boxes, drop down lists, and a few validators. The number of controls is dynamic. What would be the best way to accomplish this? What I've got so far is: - a onChange attribute for the dropdownlist, - a javascript function which gets called in the onChange event handler - this function correctly determines if I should enable or disable the rest of the row - ... and then calls getElementsByName to get an array of elements that should be enabled/disabled. But this is where I stop, since getElementsByName doesn't return anything. If I specify a name attribute for the controls that should be enabled/disabled, it won't render to the page since ASP.NET will override my setting with the id of the control. I could probably create a subclass of TextBox and DropDownList, and modify their RenderAttributes( ) function, I just haven't gotten to it yet. Is there an easier way? Even if I succeed with that, I still have the problem of disabling the validators for the controls that should be disabled. Is there some easy way to accomplish that? I found http://www.codeproject.com/useritems/ASPNET_Validation_Tamed.asp[^] which talks about similar solution, but am I missing something completely obvious? I'm aware of the fact that I could set the AutoPostBack property of the DropDownLists to true, and handle the change events server side, but I would rather do it client side just to minimize server load. But then again, if I must use server side I probably will. So anyway, any help or hints whatsoever would be highly appreciated. Regards, Daníel


    Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

    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