Click here to Skip to main content
11,503,113 members (74,908 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET checkbox
Dear Friends,

am working on Asp.net 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
good
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%>');
        if(checkbox.checked)
        {
          Textbox.disabled =false;
          Textbox.focus();
        }
        else
        {
            Textbox.disabled =true;
        }
    }
    </script>
 

<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()");
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

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

Please help.

Thanks.

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



Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 9 Sep 2012
Copyright © CodeProject, 1999-2015
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