Using CommandName to Identify specific control

  • Thread starter Thread starter Jim McGivney
  • Start date Start date
J

Jim McGivney

In VWD I have a webpage that contains a number of ImageButtons. Each
ImageButton has a unique CommandName (e.g. IB1, IB2, etc). I can tell
which ImageButton has been pressed by testing for the CommandName in the
event handler (e.CommandName = IB1). I now want to change the background
color of this ImageButton. How can I programmatically accomplish this? How
do I pragmatically access a specific ImageButton when I know its
CommandName? Sample code would be appreciated.

Thanks in advance for your help,

Jim
 
Jim McGivney said:
In VWD I have a webpage that contains a number of ImageButtons. Each
ImageButton has a unique CommandName (e.g. IB1, IB2, etc). I can tell
which ImageButton has been pressed by testing for the CommandName in the
event handler (e.CommandName = IB1). I now want to change the background
color of this ImageButton. How can I programmatically accomplish this?
How do I pragmatically access a specific ImageButton when I know its
CommandName? Sample code would be appreciated.

Instead of checking for the e.CommandName in the event handler, it will
be easier to use the "sender" argument, which refers to the object that
triggered the event.

((ImageButton)sender).BackColor = Color.Red;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top