views:

35

answers:

3

We have a service that generates a report (using word templates and a 3rd party library), and then returns a string in HTML. While this HTML isn't great - its formatted correctly in this string.

We want this HTML to show up on a page - format intact. What we currently have done is set an ASP.net Literal's text element to this string.

While this works, I have noticed that it has reformatted the HTML string slightly. For the most part, it looks like it generated a bunch of new CSS classes, and a new style element in the HTML. This HTML does not exist in the string thats being returned. I could filter all of this back out, but wonder if there is a better way.

I assume that the Page itself is altering something.

What is the best way to display this raw HTML back to the user? I can't directly use a Response.Write(string), because this page does have a few other controls on it.

A: 

I've not heard of the Literal control behaving the way you have described and not seen it behave that way whenever I have used it but I have not attempted to output html in this way before.
An alternative could be to assign the html to a public page property in your code behind file and then use server side script tags in your aspx file to display the contents of this property:

<%=HTMLString %>
Andy Rose
This is a very interesting solution, but was giving me the same result.
jmlumpkin
A: 

Literal controls do not format their text values (AFAIK), so I would guess it's something else. Possibly a response filter (Request.Filter) which could be altering the page output? Another possbility may be that a containing control might be altering the value of its child controls (i.e. your literal) in it's custom rendering.

JonoW
At first, I thought it was the Page control itself messing things up. Though, if you see my answer - it was the 3rd party library. Is there a way though to ever take away the overhead of the page control?
jmlumpkin
A: 

It was my own mistake, a setting on the third party library. I was saving my comparison page before it was messing with the CSS. Thank you for your helpful answers though - I thought I was loosing my mind!

jmlumpkin