<img alt="Upload Profile Pic" src="<%= ViewData["PicSource"].ToString() %>" />
UPDATE: Also, when we write this syntax, visual studio underlines several elements of our html code with curly red lines just like when we have some syntax errors and it looks like that the syntax we have written will not work and is wrong, but actually when I built it, it worked.
It also denies to auto format the html code. This was an enough good reason for me for asking this question because even though I knew that this syntax will work, still then when everytime I write like this, I feel that I have done something wrong.
Yes, you can write like that.
However, it is often referred to as “spaghetti code”, and the best practice would be to use a helper method.
then, you’re use looks like