Click here to Skip to main content
13,453,951 members (53,556 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Dear Friends,

am working on c# Sqlsever 2005.

I have a web page which consists of Checkbox and Textboxes.

When the first time page loads these textboxes are disabled. AND when user checks the checkbox the cursor must be placed in TEXTBOX.

Please help me. and give me one example on this

Thanks for ever
Posted 8-Sep-12 20:59pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You can use the focus() method in JavaScript.
Here is a sample code.

<script type="text/javascript">
   function setFocus()
        var checkbox = document.getElementById('<%=checkBox1.ClientID %>');
        var Textbox =  document.getElementById('<%= txtTest.ClientID%>');
          Textbox.disabled =false;
            Textbox.disabled =true;

<asp:CheckBox ID="checkBox1" runat="server" OnCheckedChanged="checkBox1_CheckedChanged"  />
  <asp:TextBox ID="txtTest" runat="server" Enabled="false"></asp:TextBox>

In your code behind file include this line under Page_Load()
checkBox1.Attributes.Add("onClick", "setFocus()");
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Ubaid ur Rahman IT 9-Sep-12 3:08am
Boss Boss................

Enable Textboxes when checkbox checked.
Ubaid ur Rahman IT 9-Sep-12 3:10am
Textboxes must be same as it is....when checkbox checked user can enter into textbox.

Please help.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03-2016 | 2.8.180321.1 | Last Updated 9 Sep 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100