473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

C# checkbox not showing textbox

42
Hi everybody.

I fairly new in developing with Visual Studio 2003. This is the scenario

I would like to have a checkbox, which when checked is going to show a textbox. I believe this should be fairly easy to do, but I just cannot make it work. When checked the program is trying to execute something, but doesn't show the box.

I'm using following handler

private void CheckBox6_CheckedChanged(object sender, System.EventArgs e)
{
if (CheckBox6.Checked==true)
{
TextBox3roads.Height=72;
TextBox3roads.Visible=true;
}
else
{
Textbox3roads.Height=0;
Textbox3roads.Visible=false;
}
}

This is the HTML part of the control

asp:checkbox id="CheckBox" runat="server" Width="400px" AutoPostBack="True"></asp:checkbox>

So what am I missing here? Could someone give me some instruction?

Thanks.
Sep 27 '06 #1
3 8716
Hi everybody.

I fairly new in developing with Visual Studio 2003. This is the scenario

I would like to have a checkbox, which when checked is going to show a textbox. I believe this should be fairly easy to do, but I just cannot make it work. When checked the program is trying to execute something, but doesn't show the box.

I'm using following handler

private void CheckBox6_CheckedChanged(object sender, System.EventArgs e)
{
if (CheckBox6.Checked==true)
{
TextBox3roads.Height=72;
TextBox3roads.Visible=true;
}
else
{
Textbox3roads.Height=0;
Textbox3roads.Visible=false;
}
}

This is the HTML part of the control

asp:checkbox id="CheckBox" runat="server" Width="400px" AutoPostBack="True"></asp:checkbox>

So what am I missing here? Could someone give me some instruction?

Thanks.

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{
TextBox1.Visible=false;

}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.CheckBox1.CheckedChanged += new System.EventHandler(this.CheckBox1_CheckedChanged) ;
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
if(CheckBox1.Checked==true)
{
TextBox1.Visible=true;
TextBox1.Height=72;
}
else
{
TextBox1.Visible=false;
}
}
Sep 29 '06 #2
nmsreddi
366 256MB
hello

you have written

if(checkbox.checked==true)

instead try this

if(checkbox.checked)
{

//code
}


this works fine at my side


regards

nmsreddi
Sep 29 '06 #3
zamuel
42
Yes, the problem was with "Web Form Designer generated code". Didn't know to add checkbox to this one. Thanks for the help.
Oct 2 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Shufen | last post by:
Hi, I'm a newbie that just started to learn python, html and etc. I have some questions to ask and hope that someone can help me on. I'm trying to code a python script (with HTML) to get...
1
by: Paul Sampson | last post by:
Hello, I've added a TableStyle and two GridColumnStyles to my datagrid in design mode, to allow setting the size of the columns. This works fine (even though it's WAY too complicated for...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
5
by: fred | last post by:
hiya, I have got a checkbox in one of my cells in the ediit item template. Now i need to enable/disable a textbox in another boundcolumn. the problem i am facing is the checkchanged event is...
5
by: Leo J. Hart IV | last post by:
Hello, I'm hoping someone can help me out. I was wondering if the Enabled property of a CheckBox or RadioButton server control is stored in the ViewState. If not, is there some way to to add...
4
by: SJ | last post by:
Hi all, I have come across a weird problem when attempting to automatically set the focus in a vb.net form to a checkbox control... In my form I have (on a tab page in a tab control) several...
2
by: UJ | last post by:
Is there a way with a asp:checkbox to run a JavaScript to display/hide text/input on the screen without doing a postback? I also need to be able to access the stuff at the server so I need to...
4
by: Matrixreloadedth | last post by:
How to change disable color of Checkbox??? I have a checkbox with forecolor in red but when i disable by set Enable properties to false forecolor is changed to gray color but i don't want it. how...
1
by: pieandpeas | last post by:
i'm trying to change a checkbox on a databound gridview, on the aspx page, i can bind <asp:TextBox ID="TextBox1" runat="server" Text ='<%# Bind("Data") %>'></asp:Textbox> result showing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.