1

我希望 an 中的所有图像都ImageButton显示在单个 div 中

 <asp:UpdatePanel ID="UPEmail" runat="server" UpdateMode="Always">
                <ContentTemplate>
                    <asp:DataList  ID="dlImages" runat="server" RepeatColumns="3" CellPadding="25" CellSpacing="25">
                    <ItemTemplate>
                    <asp:Imagebutton class="afbeelding" ID="Image1" CommandName='<%# Bind("Naam") %>' ImageUrl='<%# Bind("image", "http://url/Thumbs/{0}") %>' runat="server" style="width:200px; height: 250px; border: 2px grey solid;"  /><br />
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Naam") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:DataList>
                </ContentTemplate>
                <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddlType" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="ddlCollection" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="ddlMateriaal" EventName="SelectedIndexChanged" />
                </Triggers>
                </asp:UpdatePanel>

有没有办法做到这一点?

4

2 回答 2

1

你可以使用 CSSstyle="display:block"

因此,将您的代码更改为

<asp:Imagebutton class="afbeelding" ID="Image1" CommandName='<%# Bind("Naam") %>' ImageUrl='<%# Bind("image", "url/Thumbs/{0}") %>' runat="server" style="display:block;width:200px; height: 250px; border: 2px grey solid;"  />

阅读更多http://www.w3schools.com/cssref/pr_class_display.asp

于 2013-07-24T13:47:37.057 回答
1

根据正在更新的原始帖子进行更新...将其包装在 div 中。下面将在每个 div 上放置一个“imageWrapper”类名,并将一个唯一的“imageWrapper[Naam 在这里]”作为 ID。根据需要删除 div 的类/ID:

<asp:UpdatePanel ID="UPEmail" runat="server" UpdateMode="Always">
            <ContentTemplate>
                <asp:DataList  ID="DlImages" runat="server" RepeatColumns="3"
                    CellPadding="25" CellSpacing="25">
                <ItemTemplate>
                <div class="imageWrapper" id='<%# eval("Naam", "imageWrapper{0}") %>'>
                <asp:Imagebutton class="afbeelding" ID="Image1" CommandName='<%# Bind("Naam")%>'
                    ImageUrl = '<%# Bind("image", "http://url/{0}") %>' runat="server"
                    style="width:200px; height: 250px; border: 2px grey solid;z-index: 10;"  />
                    </div><br />
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Naam") %>'></asp:Label>
 </ItemTemplate>
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:DataList>
            </ContentTemplate>
            <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ddlType" EventName="SelectedIndexChanged" />
            <asp:AsyncPostBackTrigger ControlID="ddlCollection"
                EventName="SelectedIndexChanged" />
            <asp:AsyncPostBackTrigger ControlID="ddlMateriaal"
                EventName="SelectedIndexChanged" />
            </Triggers>
            </asp:UpdatePanel>
于 2013-07-24T13:59:59.093 回答