<%@ Page language="c#" Codebehind="Lookup.aspx.cs" AutoEventWireup="false" Inherits="aspNetDnsTest.Lookup" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> <meta name="CODE_LANGUAGE" Content="C#"> <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>
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using aspNetDns; using aspNetDns.Records; namespace aspNetDnsTest { /// <summary> /// Summary description for WebForm1. /// </summary> public class Lookup : System.Web.UI.Page { protected System.Web.UI.WebControls.Literal litMsg; protected System.Web.UI.HtmlControls.HtmlInputText txtIPAddress; private void Page_Load(object sender, System.EventArgs e) { if( Page.IsPostBack) { if( txtIPAddress.Value.Length > 0 ) { PointerRecord[] records = PointerRecord.GetPointerRecords( txtIPAddress.Value ); if( records.Length > 0 ) { litMsg.Text = string.Empty; for( int i=0;i<records.Length;i++) { litMsg.Text += "<BR>" + txtIPAddress.Value + " maps to " + records[i].PointerName; } } else { litMsg.Text = "No Records Were Found."; } } else { litMsg.Text = "Please Enter a Valid IP Address"; } } else //populate with the client IP Address { txtIPAddress.Value = Request.UserHostAddress; } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } }