asp.net如何在后台控制前台页面的image控件的宽度?
前台控件代码:<asp:ImageID="imagedutiao"Height="9px"runat="server"ImageUrl="~/resource/image...
前台控件代码:<asp:Image ID="imagedutiao" Height="9px" runat="server" ImageUrl="~/resource/images/dutiao.png"/>
后台代码:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
int wid = int.Parse(DataBinder.Eval(e.Item.DataItem, "PRAISECOUNT").ToString());
System.Web.UI.WebControls.Image tb = (System.Web.UI.WebControls.Image)e.Item.FindControl("imagedutiao");
tb.Width = new Unit(wid);
}
} 展开
后台代码:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
int wid = int.Parse(DataBinder.Eval(e.Item.DataItem, "PRAISECOUNT").ToString());
System.Web.UI.WebControls.Image tb = (System.Web.UI.WebControls.Image)e.Item.FindControl("imagedutiao");
tb.Width = new Unit(wid);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询