Link to home
Start Free TrialLog in
Avatar of EffinGood
EffinGoodFlag for United States of America

asked on

c# .net arrays - Images and ImageButtons

Hi,

I've looked everywhere but not found an answer to what should be a simple question.  How can I set up Images and ImageButtons to be dealt with as arrays?  Most "answers" to this that I've seen link to this page:

http://msdn.microsoft.com/en-us/library/aa289500%28v=vs.71%29.aspx

Which is a much more complicated solution than I need or can handle.

Here's an example.  I want to build a page that has 64 ImageButtons.  The ImageURLs for these should be set in some sort of for-loop in the code-behind, and there should be one single OnClick event that can tell which button triggered it.

Psuedo-code of what I would like to see happen:

.aspx code:

<asp:Button ID="Button1" runat="server" OnClick="Button_Click" />
<asp:Button ID="Button2" runat="server" OnClick="Button_Click" />
<asp:Button ID="Button3" runat="server" OnClick="Button_Click" />...

Code-behind:

protected void Page_Load(object sender, EventArgs e)
{
for (i=0; i<64; i++)
{
Buttoni.ImageURL=i+".png";
}
}

protected void Button_Click(object sender, EventArgs e)
{
// somehow tell which button triggered the event, and switch based on that value
}
SOLUTION
Avatar of Ajay Sharma
Ajay Sharma
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial