<%@ Page Language="vb" AutoEventWireup="false" Codebehind="pingme.aspx.vb" Inherits="aspNetPingTest.pingme"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>pingme</title> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <INPUT id=txtHost type=text runat="server" NAME="txtHost"><INPUT type=submit value=Ping ID="Submit1" NAME="Submit1"> <br> <PRE><asp:Literal id=PingResults Runat="server"></asp:Literal></PRE> </form> </body> </HTML>
Imports aspNetPing Public Class pingme Inherits System.Web.UI.Page Protected WithEvents PingResults As System.Web.UI.WebControls.Literal Protected WithEvents txtHost As System.Web.UI.HtmlControls.HtmlInputText #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Page.IsPostBack Then Dim hostToPing As String = txtHost.Value Dim reply As ReplyPacketCollection = IcmpClient.Ping(hostToPing, 4) PingResults.Text = reply.ToString() End If End Sub End Class