0

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?

3
  • What is the root virtual directory? Commented Oct 8, 2009 at 14:16
  • that would be D:\deploy\ and i got /Content/Images/pagebgbottomwhite.jpg in here Commented Oct 8, 2009 at 14:20
  • Can you definately browse directly to the image? Commented Oct 8, 2009 at 14:32

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

if i am using HttpContext.Current.Server.MapPath("~/Content/Images/pagebgbottomwhite.jpg")); it doens;t work without deploying with iis
0

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>

Comments

0

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

1 Comment

i can see that files in the deployment folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.