code_junkie

Disable asp.net radiobutton with javascript

Nov 10th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. private static void DisableControl(WebControl control)
  2. {
  3.  
  4. if (control is CheckBox)
  5. {
  6. ((CheckBox)control).InputAttributes.Add("disabled", "disabled");
  7.  
  8. }
  9. else if (control is RadioButton)
  10. {
  11.  
  12. }
  13. else if (control is ImageButton)
  14. {
  15. ((ImageButton)control).Enabled = false;
  16. }
  17. else
  18. {
  19. control.Attributes.Add("readonly", "readonly");
  20. }
  21. }
  22.  
  23. private static void DisableControl(WebControl control)
  24. {
  25. Type controlType = control.GetType();
  26.  
  27. if (controlType == typeof(CheckBox))
  28. {
  29. ((CheckBox)control).InputAttributes.Add("disabled", "disabled");
  30.  
  31. }
  32. else if (controlType == typeof(RadioButton))
  33. {
  34. ((RadioButton)control).InputAttributes.Add("disabled", "true");
  35. }
  36. else if (controlType == typeof(ImageButton))
  37. {
  38. ((ImageButton)control).Enabled = false;
  39. }
  40. else
  41. {
  42. control.Attributes.Add("readonly", "readonly");
  43. }
  44. }
Add Comment
Please, Sign In to add comment