Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set asp.net image control width and height property

i am using asp.net and c# i want to set image height and width property using c# code , i can do it , but the value will be set as an inline style like this :

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

but i want something like this

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

i use this code , but it render like css code :(

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

is there any idea?

like image 706
amin_erf Avatar asked Dec 05 '25 11:12

amin_erf


1 Answers

Just define it as attribute:

image1.Attributes.Add("width", "800");
image1.Attributes.Add("height", "220");
like image 83
Skatrix Avatar answered Dec 07 '25 01:12

Skatrix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!