
Image 1: Web form for getting page HTML at design time
using System;
using System.Text;
using System.Net;
public partial class DefaultCS : System.Web.UI.Page
{
protected void btnGetHTML_Click(object sender, EventArgs e)
{
// We'll use WebClient class for reading HTML of web page
WebClient MyWebClient = new WebClient();
// Read web page HTML to byte array
Byte[] PageHTMLBytes;
if (txtURL.Text != "")
{
PageHTMLBytes = MyWebClient.DownloadData(txtURL.Text);
// Convert result from byte array to string
// and display it in TextBox txtPageHTML
UTF8Encoding oUTF8 = new UTF8Encoding();
txtPageHTML.Text = oUTF8.GetString(PageHTMLBytes);
}
}
}
Imports System
Imports System.Text
Imports System.Net
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnGetHTML_Click(ByVal sender As Object, ByVal e As System.EventArgs)Handles btnGetHTML.Click
' We'll use WebClient class for reading HTML of web page
Dim MyWebClient As WebClient = New WebClient()
' Read web page HTML to byte array
Dim PageHTMLBytes() As Byte
If txtURL.Text <> "" Then
PageHTMLBytes = MyWebClient.DownloadData(txtURL.Text)
' Convert result from byte array to string
' and display it in TextBox txtPageHTML
Dim oUTF8 As UTF8Encoding = New UTF8Encoding()
txtPageHTML.Text = oUTF8.GetString(PageHTMLBytes)
End If
End Sub
End Class

Image 2: HTML Code is read and shown in text box