开发者

ImageButton not aligning to center

Given the following markup for a GridView column, why are my image buttons showing up as left aligned?

<ItemStyle HorizontalAlign="Center" Width="55px" />
<ItemTemplate>
    <asp:Imag开发者_如何学编程eButton ID="removeButton" runat="server" 
        ImageUrl="~/Images/Icons/x-m.png" 
        CommandArgument='<%# Eval("ResourceId") %>' 
        AlternateText="Remove Button" 
        onclick="removeButton_Click" />
</ItemTemplate>


Can you use css? You might have better luck styling using the following css.

Lets say width of x-m.png is 25px;

.X { width: 55px; }
.Y { display: block; margin: 0 auto;  width: 25px; } 

<ItemStyle cssClass="X" />
<ItemTemplate>
        <asp:ImageButton ID="removeButton" runat="server" 
        ImageUrl="~/Images/Icons/x-m.png" 
        CommandArgument='<%# Eval("ResourceId") %>' 
        AlternateText="Remove Button" 
        onclick="removeButton_Click"
        cssClass="Y"/>
</ItemTemplate>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜