Senthil Natarajan Senthil Natarajan - 1 month ago 4
C# Question

Add mulitple inline style from code behind

I know i can add style from code behind this way

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";