Ben Coffman
Ben Coffman

Reputation: 1740

Making HTML look pretty in "view Source" when I inject it via a System.web.ui.webcontrol.literal

Right now I am putting code in a literal like this.

ImageItem.Text = string.Format("<div class=\"thumb\"><img src=\"{0}\" width=\"132\" height=\"99\" /><a class=\"more\">&nbsp;</a>" +
      "<div class=\"tooltip\"><a class=\"close-tooltip\" href=\"javascript:void(0)\"><img src=\"/images/blank.gif\" /></a>" +
      "<h3>{1}</h3>" +
      "<p>{2}</p>" +
      "<a href=\"gallery_download.html\" class=\"ttlink\" rel=\"gb_page_center[640, 515]\">Click To Download</a>" +
      "<div class=\"ttmap\"><img src=\"/images/bub_star.png\" class=\"christchurch\" /></div>" +
      "</div>" +
      "</div>", ImageParams);

Right now the HTML source is basically one big long string with no line breaks. I want it to output nice and pretty like proper HTML

Example

<div>
        <div>Title</div>
        <div>Content</div>
</div>

Upvotes: 1

Views: 177

Answers (1)

Tony Abrams
Tony Abrams

Reputation: 4673

You are going to have to insert your own line breaks in the code. You can do this with the string.format to make it easier.

EDIT

For Example:

ImageItem.Text = string.Format("<div class=\"thumb\">{1}<img src=\"{0}\" width=\"132\" height=\"99\" />{1}<a class=\"more\">&nbsp;</a>{1}" +
  "<div class=\"tooltip\">{1}<a class=\"close-tooltip\" href=\"javascript:void(0)\"><img src=\"/images/blank.gif\" /></a>{1}" +
  "<h3>{1}</h3>{1}" +
  "<p>{2}</p>{1}" +
  "<a href=\"gallery_download.html\" class=\"ttlink\" rel=\"gb_page_center[640, 515]\">Click To Download</a>{1}" +
  "<div class=\"ttmap\">{1}<img src=\"/images/bub_star.png\" class=\"christchurch\" />{1}</div>{1}" +
  "</div>{1}" +
  "</div>{1}", ImageParams, "\n");

Upvotes: 1

Related Questions