Click here to Skip to main content
15,911,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: please answer me (few interview questions) Pin
Colin Angus Mackay9-Oct-07 7:14
Colin Angus Mackay9-Oct-07 7:14 
GeneralRe: please answer me (few interview questions) Pin
Pete O'Hanlon9-Oct-07 22:03
mvePete O'Hanlon9-Oct-07 22:03 
GeneralRe: please answer me (few interview questions) Pin
Colin Angus Mackay10-Oct-07 11:14
Colin Angus Mackay10-Oct-07 11:14 
QuestionScrollbar color change Pin
Darmi8-Oct-07 18:16
Darmi8-Oct-07 18:16 
GeneralOnline Pin
Skeliton8-Oct-07 16:32
Skeliton8-Oct-07 16:32 
GeneralRe: Online Pin
Scott Dorman8-Oct-07 16:39
professionalScott Dorman8-Oct-07 16:39 
Questionhow can I get ID of each control in a form ? Pin
whale848-Oct-07 14:44
whale848-Oct-07 14:44 
AnswerRe: how can I get ID of each control in a form ? [modified] Pin
Scott Dorman8-Oct-07 15:45
professionalScott Dorman8-Oct-07 15:45 
Since everything is an ImageButton, you need to cast source back to an ImageButton:
C#
public void doImage(object source, ImageClickEventArgs e)
{
   ImageButton ib = source as ImageButton;
   if (ib != null)
   {
      switch (Source.ID)
      {
         case "IB1":
            Response.Redirect("ibtest.aspx");
            break;
         case "IB2":
            Response.Redirect("another.aspx");
            break;
         case "IB3":
            Response.Redirect("third.aspx");
            break;
      }
   }
}
C#
public void doImage(object source, ImageClickEventArgs e)
{
   ImageButton ib = source as ImageButton;
   if (ib != null)
   {
      switch (ib.ID)
      {
         case "IB1":
            Response.Redirect("ibtest.aspx");
            break;
         case "IB2":
            Response.Redirect("another.aspx");
            break;
         case "IB3":
            Response.Redirect("third.aspx");
            break;
      }
   }
}
[modification at 5:37 Tuesday 9th October, 2007] As Martin# pointed out, I forgot to change the switch to use the casted source.[/modification]


Scott.

—In just two days, tomorrow will be yesterday.

[Forum Guidelines] [Articles] [Blog]

GeneralRe: how can I get ID of each control in a form ? Pin
whale848-Oct-07 17:09
whale848-Oct-07 17:09 
GeneralRe: how can I get ID of each control in a form ? Pin
Scott Dorman8-Oct-07 17:18
professionalScott Dorman8-Oct-07 17:18 
GeneralRe: how can I get ID of each control in a form ? Pin
Pete O'Hanlon8-Oct-07 22:23
mvePete O'Hanlon8-Oct-07 22:23 
GeneralRe: how can I get ID of each control in a form ? Pin
Scott Dorman8-Oct-07 23:35
professionalScott Dorman8-Oct-07 23:35 
GeneralRe: how can I get ID of each control in a form ? Pin
whale848-Oct-07 17:27
whale848-Oct-07 17:27 
GeneralRe: how can I get ID of each control in a form ? Pin
whale848-Oct-07 21:43
whale848-Oct-07 21:43 
GeneralRe: how can I get ID of each control in a form ? Pin
J4amieC8-Oct-07 22:17
J4amieC8-Oct-07 22:17 
GeneralRe: how can I get ID of each control in a form ? Pin
Scott Dorman8-Oct-07 23:34
professionalScott Dorman8-Oct-07 23:34 
GeneralRe: how can I get ID of each control in a form ? Pin
whale849-Oct-07 2:08
whale849-Oct-07 2:08 
GeneralRe: how can I get ID of each control in a form ? Pin
Scott Dorman9-Oct-07 7:45
professionalScott Dorman9-Oct-07 7:45 
GeneralRe: how can I get ID of each control in a form ? Pin
Martin#8-Oct-07 23:15
Martin#8-Oct-07 23:15 
QuestionICON!!! Pin
MasterSharp8-Oct-07 13:53
MasterSharp8-Oct-07 13:53 
AnswerRe: ICON!!! Pin
MasterSharp8-Oct-07 13:56
MasterSharp8-Oct-07 13:56 
GeneralRe: ICON!!! Pin
Luc Pattyn8-Oct-07 14:03
sitebuilderLuc Pattyn8-Oct-07 14:03 
GeneralRe: ICON!!! Pin
MasterSharp8-Oct-07 14:11
MasterSharp8-Oct-07 14:11 
GeneralRe: ICON!!! Pin
Luc Pattyn8-Oct-07 14:24
sitebuilderLuc Pattyn8-Oct-07 14:24 
GeneralRe: ICON!!! Pin
MasterSharp8-Oct-07 14:29
MasterSharp8-Oct-07 14:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.