Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

ASPX Page Control Enable / Disable

Posted on March 12, 2014October 26, 2015 By David Kittell

In some cases you need to disable controls on a page, this will help you disable various types of controls.

protected void ControlsEnabler (Control parent, bool State)
		{
		foreach (Control c in parent.Controls)
			{
			if (c is TextBox)
				{
				((TextBox)(c)).Enabled = State;
				}
			if (c is CheckBox)
				{
				((CheckBox)(c)).Enabled = State;
				}
			if (c is RadioButton)
				{
				((RadioButton)(c)).Enabled = State;
				}

			if (c is Button)
				{
				((Button)(c)).Enabled = State;
				}
			ControlsEnabler(c, State);
			}
		}
ControlsEnabler(Page, false);
Originally Posted on March 12, 2014
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

C# ASPX Code CSharp

Post navigation

Previous post
Next post

Related Posts

PowerShell – Mass Rename Files / Directories

Posted on March 25, 2019

Recently I needed to rename files and directories in a repository so I came up with the PowerShell script. NOTE: Use caution using this. cd "C:\Users\dkittell\Repos\TestRepo" Get-ChildItem -File -Recurse | Rename-Item –NewName { $_.name –replace " ","_" } # Replace space with underscore – Files Get-ChildItem -File -Recurse | Rename-Item…

Read More

BASH – Web Ping Log

Posted on January 29, 2024August 17, 2024

Sometimes you need a simple log to know when a site is up or down. Create a script like below and then put it in your crontab. #!/bin/bash echo ‘Begin ping’ if ping -c 1 kittell.net &> /dev/null; then echo "$(date "+%Y-%m-%d %H.%M.%S") – Success" >> /var/log/web_ping.log else echo "$(date…

Read More

PowerShell – Get Folder Size

Posted on November 9, 2015

function Get-FolderSize { $location = $args[0] Write-Host "Directory to Scan:"$location $value = "{0:N2}" -f ((Get-ChildItem -recurse $location | Measure-Object -property length -sum).Sum / 1MB) Write-Host "Used Storage for Directory:"$value" MB" } Get-FolderSize ("c:\temp") Reference: http://poshcode.org/5647 All information on this site is shared with the intention to help. Before any source…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes