1

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.

1

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();
}
1

Do this to get the formatted HTML value:

dDivData.Innerhtml = oListItem.GetFormattedValue("RichDataHolder").

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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