469,620 Members | 1,857 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,620 developers. It's quick & easy.

ImageButtons in an array

HI

In my first asp.Net Homepage I have the following problem:
There are some ImageButtons, witch ImageURL constantly changes. Now I would
like to create an array, so that I can assign the ImageURLs in a loop.

HTML:

<TR>
<TD><asp:imagebutton id="ImgBtn_1_1" runat="server"
ImageUrl="Image_001_001.jpg"></asp:imagebutton></TD>
<TD><asp:imagebutton id="ImgBtn_2_1" runat="server"
ImageUrl="Image_002_001.jpg"></asp:imagebutton></TD>
....
</TR>
<TR>
<TD><asp:imagebutton id="ImgBtn_1_2" runat="server"
ImageUrl="Image_001_002.jpg"></asp:imagebutton></TD>
<TD><asp:imagebutton id="ImgBtn_2_2" runat="server"
ImageUrl="Image_002_002.jpg"></asp:imagebutton></TD>
....
</TR>
....

ASP.Net:
// Create Array

int iColumns = 10;
int iRows = 5;

ImageButton[,] ImgBtn = new ImageButton[iColumns,iRows];
for(int y = 1; y <= iRows + 1; y++)
{
for(int x = 1; x <= iColumns + 1; x++)
{
ImgBtn[x,y] = "ImgBtn_x_y" ; // What to write instead of "ImgBtn_x_y"
?
}
}
....
Any idea?

Thanks
Nov 18 '05 #1
2 1847
In the Page_Load:

for i = 1 to x
Dim test As System.Web.UI.WebControls.ImageButton = New
System.Web.UI.WebControls.ImageButton()

test.imageurl = http://dfsfsfdsf

test.Style.Item("Height") = 200

test.Style.Item("Width") = 200

test.ID = "YourID" & i

AddHandler test.Command, AddressOf ImageButton_Click

Panel1.Controls.Add(test)

next
Hope this helps,

Steve
"flyAway" <fl********@gmx.at> wrote in message
news:Ve*******************@news.chello.at...
HI

In my first asp.Net Homepage I have the following problem:
There are some ImageButtons, witch ImageURL constantly changes. Now I would like to create an array, so that I can assign the ImageURLs in a loop.

HTML:

<TR>
<TD><asp:imagebutton id="ImgBtn_1_1" runat="server"
ImageUrl="Image_001_001.jpg"></asp:imagebutton></TD>
<TD><asp:imagebutton id="ImgBtn_2_1" runat="server"
ImageUrl="Image_002_001.jpg"></asp:imagebutton></TD>
...
</TR>
<TR>
<TD><asp:imagebutton id="ImgBtn_1_2" runat="server"
ImageUrl="Image_001_002.jpg"></asp:imagebutton></TD>
<TD><asp:imagebutton id="ImgBtn_2_2" runat="server"
ImageUrl="Image_002_002.jpg"></asp:imagebutton></TD>
...
</TR>
...

ASP.Net:
// Create Array

int iColumns = 10;
int iRows = 5;

ImageButton[,] ImgBtn = new ImageButton[iColumns,iRows];
for(int y = 1; y <= iRows + 1; y++)
{
for(int x = 1; x <= iColumns + 1; x++)
{
ImgBtn[x,y] = "ImgBtn_x_y" ; // What to write instead of "ImgBtn_x_y" ?
}
}
...
Any idea?

Thanks

Nov 18 '05 #2
I'm shure, it helps. I will try to translate is in c#
Thank You
"Steve Caliendo" <sc*******@epion.com> schrieb im Newsbeitrag
news:#1**************@TK2MSFTNGP09.phx.gbl...
In the Page_Load:

for i = 1 to x
Dim test As System.Web.UI.WebControls.ImageButton = New
System.Web.UI.WebControls.ImageButton()

test.imageurl = http://dfsfsfdsf

test.Style.Item("Height") = 200

test.Style.Item("Width") = 200

test.ID = "YourID" & i

AddHandler test.Command, AddressOf ImageButton_Click

Panel1.Controls.Add(test)

next
Hope this helps,

Steve
"flyAway" <fl********@gmx.at> wrote in message
news:Ve*******************@news.chello.at...
HI

In my first asp.Net Homepage I have the following problem:
There are some ImageButtons, witch ImageURL constantly changes. Now I

would
like to create an array, so that I can assign the ImageURLs in a loop.

HTML:

<TR>
<TD><asp:imagebutton id="ImgBtn_1_1" runat="server"
ImageUrl="Image_001_001.jpg"></asp:imagebutton></TD>
<TD><asp:imagebutton id="ImgBtn_2_1" runat="server"
ImageUrl="Image_002_001.jpg"></asp:imagebutton></TD>
...
</TR>
<TR>
<TD><asp:imagebutton id="ImgBtn_1_2" runat="server"
ImageUrl="Image_001_002.jpg"></asp:imagebutton></TD>
<TD><asp:imagebutton id="ImgBtn_2_2" runat="server"
ImageUrl="Image_002_002.jpg"></asp:imagebutton></TD>
...
</TR>
...

ASP.Net:
// Create Array

int iColumns = 10;
int iRows = 5;

ImageButton[,] ImgBtn = new ImageButton[iColumns,iRows];
for(int y = 1; y <= iRows + 1; y++)
{
for(int x = 1; x <= iColumns + 1; x++)
{
ImgBtn[x,y] = "ImgBtn_x_y" ; // What to write instead of

"ImgBtn_x_y"
?
}
}
...
Any idea?

Thanks


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Stormkid | last post: by
3 posts views Thread by David P. Donahue | last post: by
2 posts views Thread by charliewest | last post: by
3 posts views Thread by martin | last post: by
1 post views Thread by graphicsxp | last post: by
6 posts views Thread by rcoco | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.