Adding HTML page Content into SharePoint Page(.aspx) / Showing HTML content in SharePoint page(.aspx)

Requirement:

Read HTML file from SharePoint document library and show it inside the SharePoint page (.aspx)(Read all html files and show into custom WebPart, Onclicking the document link it should redirect to custom page where we will display the HTML file).

We tried the below code to display to HTML content inside the SharePoint page (.aspx)


C#

StreamReader srHTML = null;
string strHTML = string.Empty;
SPFile spfile = SPContext.Current.Web.Lists.TryGetList("Documents").GetItemById(45).File;
srHTML = new StreamReader(spfile.OpenBinaryStream());
strHTML = srHTML.ReadToEnd();
srHTML.Close();           

ltrHTMLContent.Text = strHTML;

asp.net

<Div style="height:500px">
        <asp:Literal ID="ltrHTMLContent" runat="server"></asp:Literal>
</Div>

The above works very well!

Comments

Popular posts from this blog

Using External Content Types with Stored Procedures with Input Parameters

NAV 2009 Issues in Role Tailored Client