tags:

views:

58

answers:

3

I have this piece of code in a .cs file in an ASP.NET MVC application:

HtmlTableCell r2c1 = new HtmlTableCell();
r2.Cells.Add(r2c1);
r2c1.ColSpan = 2;
r2c1.Style.Add("font", "1px arial");
r2c1.Style.Add("height", "10px");
r2c1.Style.Add("background-image", "url(/Content/Images/pagebgbottomwhite.jpg)");
r2c1.Style.Add("background-repeat", "repeat-x");

This works OK locally, but when I deploy my app using IIS 5 I don't see that picture.

How can I change that format of the URL so I can see it?

+1  A: 

First off, you don't really want to have this kind of code in your presenter.

As for URL format, try Server.MapPath("~/Content/Images/pagebgbottomwhite.jpg");. And ensure that this file is indeed where it should be.

Anton Gogolev
if i am using HttpContext.Current.Server.MapPath("~/Content/Images/pagebgbottomwhite.jpg")); it doens;t work without deploying with iis
gigi
@gigi: What do you exactly mean by "doesn't work"?
Anton Gogolev
A: 

You really ought to be using CSS and defining a class that has these attributes. The url would then be relative to the location of the CSS file in the site: url(../Images/pagebgbottomwhite.jpg) -- assuming that your css file is in a sibling directory to Images. Then you would apply the CSS class to your element.

I also agree with Anton that, using MVC, this code should not be in your controllers/models, but rather in the view -- in which case you would not be using HtmlTableCell. In that case, and using pure CSS, it's simply a matter of creating the proper row in the table.

  <tr><td class="bottom-row" colspan="2"></td></tr>
tvanfosson
A: 

Confirm that this file (/Content/Images/pagebgbottomwhite.jpg) is deployed. Is it set not to copy or was it left behind in deployment.

dove
i can see that files in the deployment folder
gigi