Saturday, June 20, 2009

Open other website content on my asp.net Page

here is an Tips for displaying an Otherpage content on you'r own asp.net web page

follow this steps .

  • Add new Panel


  • <asp:panel id="ViewPanel runat="server" Width="100%" >
    </asp:panel>


  • Add Namespan


  • using System.Text;using System.Net;using System.IO;

    add this namespace on your page declaration part.

  • now on Page_load() paste this code



  • protected void Page_Load(object sender, EventArgs e)
    {
    Uri weburi = new Uri(http://www.gmail.com/);
    StringBuilder str = new StringBuilder();
    string temp = "";
    HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(weburi);
    HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
    StreamReader webstream = new StreamReader(webresponse.GetResponseStream(), Encoding.ASCII);
    while ((temp = webstream.ReadLine()) != null)
    str.Append(temp + "\r\n");
    webstream.Close();
    mainpanel.Controls.Add(new System.Web.UI.LiteralControl(str.ToString()));
    }




Plz write full path on you'r URI.
that's it

No comments:

Post a Comment