Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9203719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:32:06+00:00 2026-06-17T23:32:06+00:00

We have tried to link the checkBox1 to txtCommentBox using C#. We are trying

  • 0

We have tried to link the checkBox1 to txtCommentBox using C#. We are trying to make it so that the txtCommentBox stays disabled until the checkBox1 is checked.

We’ve done the below.

if (checkBox1.Enabled)
{
    txtCommentBox.Enabled = true;
}

After that failed, we then in the page_Load method, we’ve tried to do the below.

txtCommentBox.Enabled = checkBox1.Enabled;

That didn’t work either. We’ve tried various properties with the controls with no luck.
The .aspx code is below, with the C# code further below.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Infomation.aspx.cs" Inherits="Infomation" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Information</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 605px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <h4>
            If you would like to leave your Questions, Comments, E-mail, Name or Phone 
            Number check off the box you would like to enter into the form.
        </h4>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <table class="style1">
            <tr>
                <td class="style2">
                    <asp:Label ID="Label1" runat="server"><span class="accesskey">C</span>omment:</asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="txtCommentBox" runat="server" AccessKey="C" Width="334px" 
                        ontextchanged="txtCommentBox_TextChanged" Enabled="False"></asp:TextBox>
                    <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack = "true"
                        oncheckedchanged="CheckBox1_CheckedChanged" Text="Enable/disable" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:Label ID="Label2" runat="server"><span class="accesskey">E</span>mail:</asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="txtEmailBox" runat="server" AccessKey="E" Width="334px" 
                        ontextchanged="txtEmailBox_TextChanged" Enabled="False"></asp:TextBox>
                    <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack = "true"
                        oncheckedchanged="CheckBox2_CheckedChanged" Text="Enable/disable" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:Label ID="Label3" runat="server"><span class="accesskey">N</span>ame:</asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="txtNameBox" runat="server" AccessKey="N" Width="334px" 
                        ontextchanged="txtNameBox_TextChanged" Enabled="False"></asp:TextBox>
                    <asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack = "true"
                        oncheckedchanged="CheckBox3_CheckedChanged" Text="Enable/disable" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style2">
                    <asp:Label ID="Label4" runat="server"><span class="accesskey">P</span>hone Number:</asp:Label>
                    <asp:TextBox ID="txtPhoneBox" runat="server" AccessKey="P" Width="334px" 
                        ontextchanged="txtPhoneBox_TextChanged" Enabled="False"></asp:TextBox>
                    <asp:CheckBox ID="CheckBox4" runat="server" AutoPostBack = "true"
                        oncheckedchanged="CheckBox4_CheckedChanged" Text="Enable/disable" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
        <asp:ListBox ID="ListBox1" runat="server" Height="321px" Width="887px">
        </asp:ListBox>
        <br />
        <br />
        <br />
        <br />

        <br />
        <br />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            Text="Back to the Main Page" />
        <br />

    </div>
    </form>
</body>
</html>

I’ve put our C# code for what where we’re at, below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Infomation : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            txtCommentBox.Enabled = false;
            txtEmailBox.Enabled = false;
            txtNameBox.Enabled = false;
            txtPhoneBox.Enabled = false;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("JoelsDefaultPage.aspx");
    }
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (CheckBox1.Enabled == true)
            txtCommentBox.Enabled = true;
        else
            txtCommentBox.Enabled = false;
    }
    protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
    {
        if (CheckBox2.Enabled == true)
            txtEmailBox.Enabled = true;
        else
            txtEmailBox.Enabled = false;
    }
    protected void CheckBox3_CheckedChanged(object sender, EventArgs e)
    {
        if (CheckBox3.Enabled == true)
            txtNameBox.Enabled = true;
        else
            txtNameBox.Enabled = false;
    }
    protected void CheckBox4_CheckedChanged(object sender, EventArgs e)
    {
        if (CheckBox4.Enabled == true)
            txtPhoneBox.Enabled = true;
        else
            txtPhoneBox.Enabled = false;
    }
    protected void txtCommentBox_TextChanged(object sender, EventArgs e)
    {

    }
    protected void txtEmailBox_TextChanged(object sender, EventArgs e)
    {

    }
    protected void txtNameBox_TextChanged(object sender, EventArgs e)
    {

    }
    protected void txtPhoneBox_TextChanged(object sender, EventArgs e)
    {

    }
}

EDIT #1

Okay, so the AutoPostBack sort of worked. I can now enable the textbox from its disabled state, however I cannot disable it again.

UPDATE #1

I’ve updated the code to what we have now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:32:07+00:00Added an answer on June 17, 2026 at 11:32 pm

    To check the state of a checkbox, you want to be using

    textbox.Enabled = checkBox.Checked;
    

    Rather than the enabled state of the checkbox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried using the code mentioned in the link below to mass disable
I am trying to pass a variable within a header link. I have tried
I have tried almost everything to link picture to Facebook status that is created
I have tried to do this refering to following link. http://skypher.com/index.php/2008/07/28/function-list-for-php/ But no success.
I have tried various link posted on SO,but not got reliable answer. Here is
I am having a problem, I am trying to make a link for a
I want to set order by clause dynamically. I have tried it by using
I have tried to follow some suggestions found here in other similar topics, trying
The link images refuses to center in the product box. I have tried adding
How can I put a link in a C# TextBox ? I have tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.