How to publish content from another URL in a ContentPlaceHolder control
Follow the process below to publish content from another URL in a ContentPlaceHolder Control..
|
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Literal runat=server ID="ltlContent" />
</asp:Content>
protected void Page_Load(object sender, EventArgs e)
{
try
{
WebRequest wReq = WebRequest.Create("http://yahoo.com");
WebResponse mRes = wReq.GetResponse(); StreamReader sr = new StreamReader(mRes.GetResponseStream()); string sHTML = sr.ReadToEnd(); sr.Close(); mRes.Close();
if (sHTML != string.Empty && sHTML != null)
{ ltlContent.Text = sHTML; }
}
catch (Exception eX)
{ Response.Write(eX.Message); } } |
0 comments: