Lookup.aspx


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="lookup.aspx.vb" Inherits="aspNetDnsTest.lookup"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
  <HEAD>
    <title>lookup</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
    <meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
    <meta name=vs_defaultClientScript content="JavaScript">
    <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
  </HEAD>
  <body MS_POSITIONING="GridLayout">

    <form id="Form1" method="post" runat="server">
Please enter an IP Address to lookup:
<br>
<input type=text id=txtIPAddress runat=server NAME="txtIPAddress"><input type=submit value="submit">
<asp:Literal ID=litMsg Runat=server></asp:Literal>


    </form>

  </body>
</HTML>


Lookup.aspx.vb


Imports aspNetDns
Imports aspNetDns.Records

Public Class lookup
    Inherits System.Web.UI.Page
    Protected WithEvents litMsg As System.Web.UI.WebControls.Literal
    Protected WithEvents txtIPAddress As System.Web.UI.HtmlControls.HtmlInputText

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> 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
            If txtIPAddress.Value.Length > 0 Then
                Dim records As PointerRecord() = PointerRecord.GetPointerRecords(txtIPAddress.Value)
                If records.Length > 0 Then
                    litMsg.Text = String.Empty
                    Dim i As Integer
                    For i = 0 To records.Length - 1
                        litMsg.Text += "<BR>" + txtIPAddress.Value + " maps to " + records(i).PointerName
                    Next i
                Else
                    litMsg.Text = "No Records Were Found."
                End If
            Else
                litMsg.Text = "Please Enter a Valid IP Address"
            End If

            'populate with the client IP Address
        Else
            txtIPAddress.Value = Request.UserHostAddress
        End If

    End Sub

End Class