C# 我想在asp.net aspx文件中循环映像id
这个问题与我先前的问题有关。所以点击这个链接,看看我之前的问题。 我不明白我用什么来代替我的容器。请给我举个例子。这里有一个例子:C# 我想在asp.net aspx文件中循环映像id,c#,asp.net,C#,Asp.net,这个问题与我先前的问题有关。所以点击这个链接,看看我之前的问题。 我不明白我用什么来代替我的容器。请给我举个例子。这里有一个例子: for (int i = 1; i <= 10; i++) { (MyContainer.FindControl("Image" + i) as Image).ImageUrl = "ImageCSharp.aspx?ImageID=" + PageId; } ASPX布局 protected int PageId; protected void Page
for (int i = 1; i <= 10; i++) { (MyContainer.FindControl("Image" + i) as Image).ImageUrl = "ImageCSharp.aspx?ImageID=" + PageId; }
ASPX布局
protected int PageId;
protected void Page_Load(object sender, EventArgs e)
{
PageId = 12;
for (int i = 1; i <= 10; i++)
{
Image img = MyContainer.FindControl("Image" + i) as Image;
img.ImageUrl = "ImageCSharp.aspx?ImageID=" + PageId;
}
}
MyContainer是一个保存所有图像的服务器容器 用简单的英语,你想做什么?我真的不明白你的问题。。。
<div runat="server" id="MyContainer">
<asp:image ToolTip = "ASP Image Control" ID="Image1" runat="server"></asp:image>
<asp:image ToolTip = "ASP Image Control" ID="Image2" runat="server"></asp:image>
<asp:image ToolTip = "ASP Image Control" ID="Image3" runat="server"></asp:image>
<asp:image ToolTip = "ASP Image Control" ID="Image4" runat="server"></asp:image>
</div>