Hi,
I have on my page something about 50 buttons that "user" should use only for
loading some session-variables:
click on the button -> session variables loaded
and i wish that after click, clicked button changes his color and thats no
problem. I use:
Button43.Color=red; ... or something like this... and it works
But here is the problem:
if i after clicking on Button43, wish to click on Button12, my Button 12
also become red (and thats good), but Button43 stays red (and thats bad)!
and i wish that Button43 gets his old/unclicked color!
I want this:
I push one button and this button get his "clicked" color, and all other
buttons should get their "unclicked" color independent (!) on their previous
color/state (clicked or unclicked)...
Thanks in advance,
Krunom. 10 1241
Hi,
earlier we had control array concepts , with that we can solve this easily.
But now in .NET you can try the following way for your need.
Loop through the controls in the page.... and if you find a control is a
button and it is not that one you clicked then make it's collour as unclicked
color. This way you can do it.
foreach (Control control in this.Controls)
{
if (control is Button)
Or you could keep the latest button pressed.
You could also have cheboxes or radio buttons allowing to depending on
wether or not the user should be able to load several values at once or not
and have a single button that loads the selected values...
Patrice
--
"DotNetJerome" <reachjerome@_yahoo.com-remove-the-underscore-after@> a écrit
dans le message de
news:35**********************************@microsof t.com... Hi,
earlier we had control array concepts , with that we can solve this
easily. But now in .NET you can try the following way for your need.
Loop through the controls in the page.... and if you find a control is a button and it is not that one you clicked then make it's collour as
unclicked color. This way you can do it.
foreach (Control control in this.Controls) { if (control is Button) . . . }
The loop must be called in the clcik event of all the buttons.
Cheers,
Jerome. M
"Krunom Ancini" wrote:
Hi,
I have on my page something about 50 buttons that "user" should use only
for loading some session-variables:
click on the button -> session variables loaded
and i wish that after click, clicked button changes his color and thats
no problem. I use:
Button43.Color=red; ... or something like this... and it works
But here is the problem:
if i after clicking on Button43, wish to click on Button12, my Button 12 also become red (and thats good), but Button43 stays red (and thats
bad)! and i wish that Button43 gets his old/unclicked color!
I want this: I push one button and this button get his "clicked" color, and all other buttons should get their "unclicked" color independent (!) on their
previous color/state (clicked or unclicked)...
Thanks in advance,
Krunom.
Krunom,
\\\
private void Page_Load(object sender, System.EventArgs e)
{
if (IsPostBack)
{
Control frm = this.FindControl("Form1");
foreach (Control ctl in frm.Controls)
if (ctl is Button)
((Button) ctl).BackColor =
System.Drawing.Color.Azure;
}}
///
And then set the buttoncolor in the normal event to its color.
I hope this helps?
Cor
If your buttons name's follow a pattern, you can use an indexer and loop
like this.
Button button = null;
int buttonIndex = 0x1;
while (null != (button = base.FindControl(string.Concat("Button",
buttonIndex ++.ToString())) as Button))
{
button.BackColor = System.Drawing.Color.Azure;
}
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Krunom Ancini" <kr****@hotmail.com> wrote in message
news:38*************@individual.net... Hi,
I have on my page something about 50 buttons that "user" should use only for loading some session-variables:
click on the button -> session variables loaded
and i wish that after click, clicked button changes his color and thats no problem. I use:
Button43.Color=red; ... or something like this... and it works
But here is the problem:
if i after clicking on Button43, wish to click on Button12, my Button 12 also become red (and thats good), but Button43 stays red (and thats bad)! and i wish that Button43 gets his old/unclicked color!
I want this: I push one button and this button get his "clicked" color, and all other buttons should get their "unclicked" color independent (!) on their previous color/state (clicked or unclicked)...
Thanks in advance,
Krunom.
I would have all of the buttons call the same event!
"DotNetJerome" <reachjerome@_yahoo.com-remove-the-underscore-after@> wrote
in message news:35**********************************@microsof t.com... Hi,
earlier we had control array concepts , with that we can solve this easily. But now in .NET you can try the following way for your need.
Loop through the controls in the page.... and if you find a control is a button and it is not that one you clicked then make it's collour as unclicked color. This way you can do it.
foreach (Control control in this.Controls) { if (control is Button) . . . }
The loop must be called in the clcik event of all the buttons.
Cheers,
Jerome. M
"Krunom Ancini" wrote:
Hi,
I have on my page something about 50 buttons that "user" should use only for loading some session-variables:
click on the button -> session variables loaded
and i wish that after click, clicked button changes his color and thats no problem. I use:
Button43.Color=red; ... or something like this... and it works
But here is the problem:
if i after clicking on Button43, wish to click on Button12, my Button 12 also become red (and thats good), but Button43 stays red (and thats bad)! and i wish that Button43 gets his old/unclicked color!
I want this: I push one button and this button get his "clicked" color, and all other buttons should get their "unclicked" color independent (!) on their previous color/state (clicked or unclicked)...
Thanks in advance,
Krunom.
Dennis Myrén <de****@oslokb.no> wrote: If your buttons name's follow a pattern, you can use an indexer and loop like this. Button button = null; int buttonIndex = 0x1; while (null != (button = base.FindControl(string.Concat("Button", buttonIndex ++.ToString())) as Button)) { button.BackColor = System.Drawing.Color.Azure; }
Or, much better IMO, would be to have an array of buttons:
Button[] buttons = new Button[50];
Then create the buttons dynamically (rather than with the designer),
say from a list of strings. Then it's really easy to add a particular
event handler to all buttons, etc.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
If you're looking for a quick and dirty hack, you could (assuming nothing
else on the page depends on it) disable the ViewState for the page. Then the
other buttons would simply "forget" they had been pressed.
A less heavy-handed version would be to disable ViewState just on the buttons.
But again, this is a bit of a hack and probably not a solution for the
purists ;)
"Krunom Ancini" wrote: Hi,
I have on my page something about 50 buttons that "user" should use only for loading some session-variables:
click on the button -> session variables loaded
and i wish that after click, clicked button changes his color and thats no problem. I use:
Button43.Color=red; ... or something like this... and it works
But here is the problem:
if i after clicking on Button43, wish to click on Button12, my Button 12 also become red (and thats good), but Button43 stays red (and thats bad)! and i wish that Button43 gets his old/unclicked color!
I want this: I push one button and this button get his "clicked" color, and all other buttons should get their "unclicked" color independent (!) on their previous color/state (clicked or unclicked)...
Thanks in advance,
Krunom.
Jon,
I agree, that would be the best solution.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Dennis Myrén <de****@oslokb.no> wrote: If your buttons name's follow a pattern, you can use an indexer and loop like this. Button button = null; int buttonIndex = 0x1; while (null != (button = base.FindControl(string.Concat("Button", buttonIndex ++.ToString())) as Button)) { button.BackColor = System.Drawing.Color.Azure; }
Or, much better IMO, would be to have an array of buttons:
Button[] buttons = new Button[50];
Then create the buttons dynamically (rather than with the designer),
say from a list of strings. Then it's really easy to add a particular
event handler to all buttons, etc.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Dennis, I agree, that would be the best solution.
Why
Be aware that this is about a webform
Cor
Cor Ligthert <no************@planet.nl> wrote: Dennis,
I agree, that would be the best solution.
Why
Be aware that this is about a webform
Because whatever kind of solution it is, dealing with an ordered
collection of objects is almost always easier if that collection is
easily indexed. An array (or list) provides that ability very simply.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lyn |
last post by:
Hi,
I hope someone can help.
I have a main form which mostly fills the Access window. In the bottom half
of this form I have a tab control to display various types of data related
to the main...
|
by: Ron |
last post by:
I want to create 10 buttons on a form at runtime, the code below is
only creating one button labeled 1. Any idea what I am doing wrong?
Public Class Form1
Public code(10) As String
Public...
|
by: Ron |
last post by:
Can anyone help me out? I am trying to add buttons numbered one
through 10 at runtime to a form.
I think they are getting added but they seem to be getting stacked one
on top of each other. so...
|
by: dpazza |
last post by:
Hi,
I'm creating a quiz on using a form in VB 2005 express.
I have four sets of questions and answers (labels and radio buttons)
and I change between which set of questions is currently shown on...
|
by: Blasting Cap |
last post by:
I have a page that has a number of radio buttons that will be displayed
to different access levels of a user who logs in to my website.
For instance, if there are a dozen buttons, user1 will see...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |