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. 9 1188
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
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: Ralph Freshour |
last post by:
Is it possible to inhibit the browser Back/Fwd buttons via PHP?
Thanks...
|
by: Bob Lehmann |
last post by:
Hi,
I pretty sure I've seen this problem addressed before, but I can't find any
references.
The short story is that I have I have multiple submit buttons on a page,
each providing different...
|
by: Aravind |
last post by:
Hi folks.
I have a form, frmHistory, which has 4 command buttons: Sort Title
(cmdSortTitle), Sort Name (cmdSortName), Due Today (cmdDueToday), and
Due List (cmdDueList).
Sort Title and Sort...
|
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: Denburt |
last post by:
This code is for a Toggle Button layout on a form, with this code you can set a number of toggle buttons visible and have multiple submenus that will stay hidden when not in use. My main menu is set...
|
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: remya1000 |
last post by:
hai i'm using Vb.net.
i'm creating 64 dynamic created buttons of 8 rows and 8 columns. And i have 1 Go button, 1 textbox. those were created dynamically. if i enter one number inside textbox and...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |