|
How to add image to the masterpage
|
|
|
|
|
To Master Page? Way to adding picture to master or Web Form, are same. If you want to add image via HTML, write this code:
<img id="pic" runat="server" alt="" />
And to code behind add following code:
...
pic.Src="path to the picture";
...
Of course, you can add image via asp:Image, but adding image by HTML is better solution, because ASP.NET server control add a some value to _VIEWSTATE, add prefix before id...
|
|
|
|
|
Adding image to normal webpage and masterpage are same. At times, you might face issue with image display because of the image relative path issue because of page hierarchies.
For such cases, you would need to make sure that the path is correct such that file is found and used.
I would suggest you to use this Tip and resolve the path correctly before setting the source: Resolving Paths in a Multi-Folder WebSite[^]
|
|
|
|