Friday, June 5, 2009

ASP.NET Master page Set Background Image to Table

Problem :When we set ASP Net - Master Page background image it only visible from pages in root directory
Solution : The images which are used in Masterpage should be set in the code behind file as fallow .
The runat='Server" attribute should be added to the controller which are going to set background image and ID should be set to that controller.
<td runat="server" id="tb1">set back ground image with code</td>

In the code behind page image should be set using ResolveClientUrl() method
protected void Page_Load(object sender, EventArgs e)
{
tb1.Style[HtmlTextWriterStyle.BackgroundImage] = ResolveClientUrl("~/App_Themes/Images/1-sri-lanka.JPG");
}


1 comment: