|
-
January 21st, 2010, 07:56 AM
#1
[RESOLVED] bool value does not change!
I am still having trouble with my button event handler... When a button is clicked btnSkillSelected should turn to true and the button should turn light blue. When another button is clicked (case 1 in If statement) then the button previously clicked should be returned to it's transparent color. The latest selected button should then turn light blue. For some reason the value of btnSkillSelected always keeps the same value: false.
Code:
public bool btnSkillSelected;
protected void Page_Load(object sender, EventArgs e)
{
btnSkillSelected = false; // I TRIED COMMENTING THIS OUT BUT GOT SAME RESULT!
}
// If a btn has been enabled before
if (btnSkillSelected == true)
{
MessageBox("Test: A button is already selected!");
// Find the previously selected btn
for (int i = 0; i < criterium.Length; i++)
{
if (btnSkill.ID == Convert.ToString(selectedSkillID))
{
// Disable the previously selected button
btnSkill.BackColor = System.Drawing.Color.Transparent;
btnSkill.Enabled = true;
}
}
}
else
{
MessageBox("Test: Button selected for first time");
}
// True for both methods:
// Show that a button has been enabled
btnSkillSelected = true;
// Change state of currently selected btn
btnSkill = (Button)sender;
selectedSkillID = int.Parse(btnSkill.ID);
btnSkill.BackColor = System.Drawing.Color.LightBlue;
btnSkill.Enabled = false;
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|