Wednesday 17 October 2012

Display HTML Content of a Website in Your Webpage

Display HTML Content of a Website in Your Webpage


This is another new interesting technique by which u could display the content of any website in your webpage.I am displaying the html content inside a label. Have a look at the code snippet below..

Design Part:

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Code Behind:

Include the namespace:

Using System.IO;
Using System.Net;

    protected void Page_Load(object sender, EventArgs e)


        Label1.Text = HttpContent("");


    private string HttpContent(string url)


        System.Net.WebRequest objRequest = System.Net.HttpWebRequest.Create(url);

        System.IO.StreamReader sr = new      System.IO.StreamReader(objRequest.GetResponse().GetResponseStream());

        string result = sr.ReadToEnd();


        return result;


No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top