C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Disabling/Enabling Controls w/Checkbox


Posted Date: 24 Jan 2008    Resource Type: Code Snippets    Category: ADO.NET

Posted By: Mohan       Member Level: Gold
Rating:     Points: 10



Sometimes it becomes necessary to enable or disable a controls, or group of controls on a web page, based on choices made in that page. Controls which could govern this type of change include Checkboxes or RadioButtons, for example. Naturally, if there were multiple controls which need to be enabled or disabled in this manner, it would be better to put them all in a container control, like the Panel.

This sample shows how to do this, using 2 checkboxes. Using the 'OnCheckChanged' event of the Checkbox, it's very easy to get this scenario setup quickly.


<script language="VB" Runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
EnableCheckBox
End Sub

Sub doIt(Source as Object, E as EventArgs)
EnableCheckBox
End Sub

Sub EnableCheckBox()
if chk1.checked="True" then
chk2.Enabled="True"
else
chk2.enabled="False"
End If
End Sub
</script>
<html>
<head>
<meta name="GENERATOR" Content="ASP Express 5.0">
<title>Disabling/Enabling Controls w/Checkbox</title>
</head>
<body>
<form id="form1" Runat="server">
<asp:Checkbox Text="Check box #1" id="chk1" AutoPostBack="true"
OnCheckedChanged="doIt" Runat="server" />
<asp:Checkbox Text="Check box #2" id="chk2" Runat="server" />
</form>
</body>
</html>




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Assigning values for Null values in sql server
Previous Resource: Excel to Dataset
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use