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).
i 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 is working very perfect.
Happy coding. I hope this will helps you....
Comments
Post a Comment