2016-11-28 90 views
2

我正在使用asp.net和c# 我想设置图像高度和宽度属性使用C#代码,我可以做到这一点,但值将被设置为内嵌样式 这样的:如何设置asp.net图像控件的宽度和高度属性

<img id="image1" style="height:220px;width:800px;border-width:0px;"> 

,但我想是这样的

<img id="image1" width="800" height="220"> 

我用这个代码,但它使像CSS代码:(

image1.Width = 800; 
    image1.Height =220; 

有什么想法吗?

回答

1

只是把它定义为属性:

image1.Attributes.Add("width", "800"); 
image1.Attributes.Add("height", "220"); 
相关问题