Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to make all my page controls read only in one go
Message
 
 
À
25/03/2004 10:17:35
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires Web
Divers
Thread ID:
00889604
Message ID:
00891359
Vues:
22
This message has been marked as the solution to the initial question of the thread.
>I have a VB Data Entry Web form

>I need to switch most of the controls on this to read only under program control.
>
>I can write code set each controls enabled property to false one at a time, but this seems a PITA to do for every form I write.
>
>I need to be able to say make everything disabled apart from .........
	' Assuming Option Strict On

	' System.Web.UI.WebControls. appears to be optional.

	Dim oControl As Control
	Dim oTextBox As New System.Web.UI.WebControls.TextBox()
	Dim oDropDown As New DropDownList()
	Dim oCheckBox As New CheckBox()
	Dim oListBox As New ListBox()
	Dim oRadioButton As New RadioButton()
	Dim oButton As New Button()

	' Note that on my web form the controls I am looking for are in Item(1).Controls

	For Each oControl In Me.Controls.Item(1).Controls

		Select Case oControl.GetType.ToString

		Case oTextBox.GetType.ToString
			oTextBox = CType(oControl, TextBox)
			oTextBox.Enabled = False

		Case oDropDown.GetType.ToString
			oDropDown = CType(oControl, DropDownList)
			oDropDown.Enabled = False

		Case oCheckBox.GetType.ToString
			oCheckBox = CType(oControl, CheckBox)
			oCheckBox.Enabled = False

		Case oListBox.GetType.ToString
			oListBox = CType(oControl, ListBox)
			oListBox.Enabled = False

		Case oRadioButton.GetType.ToString
			oRadioButton = CType(oControl, RadioButton)
			oRadioButton.Enabled = False

		Case oButton.GetType.ToString
			oButton = CType(oControl, Button)
			'oButton.Enabled = False

		End Select

	Next oControl
censored.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform