ImageButtons in an array

  • Thread starter Thread starter flyAway
  • Start date Start date
F

flyAway

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
 
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
 
I'm shure, it helps. I will try to translate is in c#
Thank You


Steve Caliendo said:
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 said:
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
 
Back
Top