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