Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Scenario : Sharepoint 2010 foundation site with a custom ASPX page. The custom ASPX page has a webpart wherein I read the contents of a multi-richtext field from a list.

I want to know within the webpart which is best control to get exactly whatever is typed or pasted within multi-richtext field.

Currently I am using DIV and innerhtml (something like this)

dDivData.Innerhtml = oListItem["RichDataHolder"].ToString();

Problem I am facing is some of the images (either pasted from different location or uploaded to siteAssets library) and tables (like table with a header and 5 columns) do not get displayed.

I am thinking something is getting messed up because of "innerhtml". I tried with "Literal" and it has same problem too.

Can anyone suggest the best options? If it is required to have different approach also, please suggest.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Try something like this...

in the .ASPX (...or .ASCX if you're using a User Control) file:

<div><%=this._innerHtml%></div>

in the C# code-behind (.ASPX.CS or .ASCX.CS):

private string _innerHtml;

protected void Page_Load(object sender, EventArgs e)
{
    _innerHtml = oListItem["RichDataHolder"].ToString();
}
share|improve this answer
add comment

Do this to get the formatted HTML value:

dDivData.Innerhtml = oListItem.GetFormattedValue("RichDataHolder").
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.