简体   繁体   中英

Add mulitple inline style from code behind

I know i can add style from code behind this way

imgStory1.Style.Add("display","block");
imgStory1.Style.Add("border", "none"); 
imgStory1.Style.Add("outline", "none");
imgStory1.Style.Add("height", "auto !important");

and so on, but I would like to do it in a much efficient way if possible. Please note I cannot do this through CSS it has to be inline styling.

Here is a way to write it in one line

imgStory1.Attributes.Add("style", "display: center;border: none; outline: none");

for overwriting existing

imgStory1.Attributes["style"] = "display: center;border: none; outline: none";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM