Web control for catching IP address and MAC address

Hi guys. I would like to know if any of you know a link or maybe have a library which allows me to use a textbox for enter an IP Address or a MAC address??. I've been searching on the web but all of the examples are for windows applications or they are masks for the normal textbox but they don't include the Control type for an IP address or a MAC address. Please help with this.

0
gabriel_mcv
3/3/2008 9:29:14 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

4 Replies
665 Views

Similar Articles

[PageSpeed] 48

 You would need to make a composite control of 4 textboxes.


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
TATWORTH
3/3/2008 10:10:35 PM

Ok, that's what I'm doing now. I'm trying to parsing the code of a windows form customized control that I downloaded, which allows to enter an IP address. But I need to know how to detect Key events inside my control, in order to code the validations of my control? For example, when I hit the Dot Key (.) on my keyboard, I need to detect that event in order to validate that the cursor passes to the next textbox in my composed control for filling the numbers of an IP address. I'm using a web controls class library project. Here's the code of the control (take a look in the event "Box1_KeyPress" at the end ):

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IPTextBOx
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
    public class IPTextBox : WebControl
    {
        private System.Web.UI.WebControls.Panel panel1;
        private System.Web.UI.WebControls.TextBox Box1;
        private System.Web.UI.WebControls.Label label1;
        private System.Web.UI.WebControls.TextBox Box2;
        private System.Web.UI.WebControls.TextBox Box3;
        private System.Web.UI.WebControls.TextBox Box4;
        private System.Web.UI.WebControls.Label label2;
        private System.Web.UI.WebControls.Label label3;
        //private System.Web.UI.WebControls. toolTip1;
        private System.ComponentModel.IContainer components;
        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string Text
        {
            get
            {
                String s = (String)ViewState["Text"];
                return ((s == null) ? String.Empty : Box1.Text + "." + Box2.Text + "." + Box3.Text + "." + Box4.Text);
            }

            set
            {
                if (value != "" && value != null)
                {
                    string[] pieces = new string[4];
                    pieces = value.ToString().Split(".".ToCharArray(), 4);
                    Box1.Text = pieces[0];
                    Box2.Text = pieces[1];
                    Box3.Text = pieces[2];
                    Box4.Text = pieces[3];
                }
                else
                {
                    Box1.Text = "";
                    Box2.Text = "";
                    Box3.Text = "";
                    Box4.Text = "";
                }
                //ViewState["Text"] = value;
            }
        }
        public bool IsValid()
        {
            try
            {
                int checkval = int.Parse(Box1.Text);
                if (checkval < 0 || checkval > 255)
                    return false;
                checkval = int.Parse(Box2.Text);
                if (checkval < 0 || checkval > 255)
                    return false;
                checkval = int.Parse(Box3.Text);
                if (checkval < 0 || checkval > 255)
                    return false;
                checkval = int.Parse(Box4.Text);
                if (checkval < 0 || checkval > 255)
                    return false;
                else
                    return true;
            }
            catch
            {
                return false;
            }
        }

        protected override void RenderContents(HtmlTextWriter output)
        {
            output.Write(Text);
        }

        private bool IsValid(string inString)
        {
            try
            {
                int theValue = int.Parse(inString);
                if (theValue >= 0 && theValue <= 255)
                    return true;
                else
                {
                    //alert("Must Be Between 0 and 255", "Out Of Range");
                    return false;
                }
            }
            catch
            {
                return false;
            }
        }
        private void Box1_KeyPress(object sender, System.EventArgs e)
        {
            //Only Accept a '.', a numeral, or backspace
            if (e.KeyChar.ToString() == "." || Char.IsDigit(e.KeyChar) || e.KeyChar == 8)
            {
                //If the key pressed is a '.'
                if (e.KeyChar.ToString() == ".")
                {
                    //If the Text is a valid ip octet move to the next box
                    if (Box1.Text != "" && Box1.Text.Length != Box1.SelectionLength)
                    {
                        if (IsValid(Box1.Text))
                            Box2.Focus();
                        else
                            Box1.SelectAll();
                    }
                    e.Handled = true;
                }

                //If we are not overwriting the whole text
                else if (Box1.SelectionLength != Box1.Text.Length)
                {
                    //Check that the new Text value will be a valid
                    // ip octet then move on to next box
                    if (Box1.Text.Length == 2)
                    {
                        if (e.KeyChar == 8)
                            Box1.Text.Remove(Box1.Text.Length - 1, 1);
                        else if (!IsValid(Box1.Text + e.KeyChar.ToString()))
                        {
                            Box1.SelectAll();
                            e.Handled = true;
                        }
                        else
                        {
                            Box2.Focus();
                        }
                    }
                }
            }
            //Do nothing if the keypress is not numeral, backspace, or '.'
            else
                e.Handled = true;
        }
    }
}

 

Please help me it's urgent

0
gabriel_mcv
3/4/2008 5:17:12 PM

Ok, that's what I'm doing now. I'm trying to parsing the code of a windows form customized control that I downloaded, which allows to enter an IP address. But I need to know how to detect Key events inside my control, in order to code the validations of my control? For example, when I hit the Dot Key (.) on my keyboard, I need to detect that event in order to validate that the cursor passes to the next textbox in my composed control for filling the numbers of an IP address. I'm using a web controls class library project. Here's the code of the control (take a look in the event "Box1_KeyPress" at the end ):

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IPTextBOx
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")]
    public class IPTextBox : WebControl
    {
        private System.Web.UI.WebControls.Panel panel1;
        private System.Web.UI.WebControls.TextBox Box1;
        private System.Web.UI.WebControls.Label label1;
        private System.Web.UI.WebControls.TextBox Box2;
        private System.Web.UI.WebControls.TextBox Box3;
        private System.Web.UI.WebControls.TextBox Box4;
        private System.Web.UI.WebControls.Label label2;
        private System.Web.UI.WebControls.Label label3;
        //private System.Web.UI.WebControls. toolTip1;
        private System.ComponentModel.IContainer components;
        [Bindable(true)]
        [Category("Appearance")]
        [DefaultValue("")]
        [Localizable(true)]
        public string Text
        {
            get
            {
                String s = (String)ViewState["Text"];
                return ((s == null) ? String.Empty : Box1.Text + "." + Box2.Text + "." + Box3.Text + "." + Box4.Text);
            }

            set
            {
                if (value != "" && value != null)
                {
                    string[] pieces = new string[4];
                    pieces = value.ToString().Split(".".ToCharArray(), 4);
                    Box1.Text = pieces[0];
                    Box2.Text = pieces[1];
                    Box3.Text = pieces[2];
                    Box4.Text = pieces[3];
                }
                else
                {
                    Box1.Text = "";
                    Box2.Text = "";
                    Box3.Text = "";
                    Box4.Text = "";
                }
                //ViewState["Text"] = value;
            }
        }
        public bool IsValid()
        {
            try
            {
                int checkval = int.Parse(Box1.Text);
                if (checkval < 0 || checkval > 255)
                    return false;
                checkval = int.Parse(Box2.Text);
                if (checkval < 0 || checkval > 255)
                    return false;
                checkval = int.Parse(Box3.Text);
                if (checkval < 0 || checkval > 255)
                    return false;
                checkval = int.Parse(Box4.Text);
                if (checkval < 0 || checkval > 255)
                    return false;
                else
                    return true;
            }
            catch
            {
                return false;
            }
        }

        protected override void RenderContents(HtmlTextWriter output)
        {
            output.Write(Text);
        }

        private bool IsValid(string inString)
        {
            try
            {
                int theValue = int.Parse(inString);
                if (theValue >= 0 && theValue <= 255)
                    return true;
                else
                {
                    //alert("Must Be Between 0 and 255", "Out Of Range");
                    return false;
                }
            }
            catch
            {
                return false;
            }
        }
        private void Box1_KeyPress(object sender, System.EventArgs e)
        {
            //Only Accept a '.', a numeral, or backspace
            if (e.KeyChar.ToString() == "." || Char.IsDigit(e.KeyChar) || e.KeyChar == 8)
            {
                //If the key pressed is a '.'
                if (e.KeyChar.ToString() == ".")
                {
                    //If the Text is a valid ip octet move to the next box
                    if (Box1.Text != "" && Box1.Text.Length != Box1.SelectionLength)
                    {
                        if (IsValid(Box1.Text))
                            Box2.Focus();
                        else
                            Box1.SelectAll();
                    }
                    e.Handled = true;
                }

                //If we are not overwriting the whole text
                else if (Box1.SelectionLength != Box1.Text.Length)
                {
                    //Check that the new Text value will be a valid
                    // ip octet then move on to next box
                    if (Box1.Text.Length == 2)
                    {
                        if (e.KeyChar == 8)
                            Box1.Text.Remove(Box1.Text.Length - 1, 1);
                        else if (!IsValid(Box1.Text + e.KeyChar.ToString()))
                        {
                            Box1.SelectAll();
                            e.Handled = true;
                        }
                        else
                        {
                            Box2.Focus();
                        }
                    }
                }
            }
            //Do nothing if the keypress is not numeral, backspace, or '.'
            else
                e.Handled = true;
        }
    }
}

 

Please help me it's urgent

0
gabriel_mcv
3/4/2008 5:17:15 PM

>But I need to know how to detect Key events inside my control, in order to code the validations of my control? For example, when I hit the Dot Key (.) on my keyboard, I need to detect that event in order to validate that the cursor passes to the next textbox in my composed control for filling the numbers of an IP address

You would need to do this in Javacript.


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
TATWORTH
3/4/2008 9:26:42 PM
Reply:

Similar Artilces:

web address changing to ip address
hi all i have a dedicated server.i hosted all files in to dedicated server ...all my web files is working properly.... when i access my web through dedicated server ip address,the web is working fine... when i access my web through web address ,the browser web address is changing to dedicated ip address for eg:my dedicated server ip address is 1.2.3.4 my web address in the dedicated server is www.test.com when i access my web through http://1.2.3.4  web is coming and the web address is  http://1.2.3.4 when i access my web through  http://www.test.com ,web is com...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

web web web
Name: bahadir Email: sensiz_olmuyor_t1_at_hotmail.com Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfası yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: http://dotnetslackers.com/Community/blogs/haissam/archive/2007/11/26/ways-to-pass-data-between-webforms.aspxSSNPlease remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

Web control in web control
Hi,There are two simple web user controls A and B, where B contains A. They just display the bunch of text boxes, so I do not need them even in tool pane. They sit in the same project next to web form.I noticed that web user control put on ASPX page does not appear in code behind, but if I create it with protected keyword and name being exactly the same as id it works fine. I can access such a web control from code behind and see the value assigned in IE. The problem is that the same routine does work for my A web control in B. When I assign the value IE, I keep getting null reference. ...

Get client IP address [Not Host] in C# .NET web services
I create one web service using c# .net and in this web service I want to get an IP address for client. I check thousend of article but that is not working, let me give you one example System.Web.HttpContext.Current.Request.UserHostAddress; System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; This is gives me IP but that my server ip where I put my web service but I want to get my client IP address. Can someone help me with this.http://www.codegroups.com/blog/ You can try: string ip; ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR"); i...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

Web Address does not appear in Address Bar
Name: Faraz Azhar Email: itz_faraz_at_hotmail.com Product: Firefox Summary: Web Address does not appear in Address Bar Comments: When we open a new tab and try to load a page from the Bookmarks menu, and for some reason that page doesn't open, its address does not appear in the Address Bar. So we cant refresh the page. You should program FireFox that before it even starts loading a page, it should make sure that it first displays the address in the address bar. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6 ...

IP address vs MAC address
Ok somebody explain this to me. I understand how IP addresses are issued(well sort of...lol) Is it one IP address to one MAC address?(not accounting for non routable IP space) I understand there can only be one WAN facing IP address per machine/MAC/NIC/etc realizing multiple NICs possible on one computer. If that is the case then how can say a Comcast DHCP server keep from issuing an IP to a MAC address that another provider has already issued an IP for? In this case perhaps someone has made up a MAC address to use in their router for cloning purposes. Or does it really ...

Get IP address and MAC address
Hi there! How can get ip address and mac address from command shell without root attributes(I can't use 'ifconfig'). Thank you in advance. -- [Adri�n C�rdoba] ------------------------------------------------------------------------ aecordoba wrote: > Hi there! > How can get ip address and mac address from command shell without root > attributes(I can't use 'ifconfig'). > Thank you in advance. > > /sbin/ifconfig -- Vahis aecordoba wrote: > Hi there! > How can get ip address and mac address from command shell wi...

Web Form and Web User Control
Hello, I have a Web User Control (ascx) that includes a button. This button has an onclick event method. This Web User control is included into a Web Form. (thru LoadControl). However, when I click on the button, the event method is not executed. What should I include in order it works fine? Thanks in advance. GAA. Using Loadcontrol is using dynamic controls and when using dynamic controls you must recreate the same dynamic controls ono postback to econstruct the page control tree. It is best if you do this during the Page PreInit event. How complex are your controls ...

how to find ip address from mac address?
It happened more than once. At a customer's office, there is a device with an unknown ip address. We know its mac address. The ip address might be different from the network. For example, the customer's network might be 10.1.0.0/16, whereas that device might have the ip address 192.168.200.123/24. For example, it might be a managed switch that has kept its default ip address. So, it works as a switch, but I cannot manage it. Apart from a sniffer, is there a (free?) software that can scan the network and find ip addresses of all hosts, and/or only of those whose mac address ...

IP Address allocation by mac address
Is it possible to give a specific mac address a fixed IP address when it requests an address from the DHCP server? mike.dawson@scarborough.gov.uk schrieb: >Is it possible to give a specific mac address a fixed IP address when it >requests an address from the DHCP server? Yes. Just create an ip-address-object with manual assignment type in the DNS/DHCP management console. Enter the mac-address, unload and reload the dhcpsrvr module and release and renew the address at the workstation. Important: Don�t touch the client identifier field, when creating the object. J...

Find an IP address having only the MAC address
Hi again, I've been searching google for a while about this issue, but I'm still too confused. My goal is to discover the IP address of the LAN interface of a Cisco 1721 router (it's located at the office where I work). I know the MAC address because it's written in a sticker at the bottom of the router. But I don't know the password to the router admin console :( The router's LAN interface is connected to a Sun workstation that has two NICs (one of them connected to the cisco and the other connected to a 24- port switch). The Sun machine works as a...

Web resources about - Web control for catching IP address and MAC address - asp.net.web-forms

Catching the Wolf of Wall Street - Wikipedia, the free encyclopedia
Catching the Wolf of Wall Street: More Incredible True Stories of Fortunes, Schemes, Parties, and Prison is the second non-fiction book by former ...

Facebook Weekly Highlights Brings You ‘The Hunger Games: Catching Fire’
... on the homepage of singer Usher giving a shout-out to electronic duo Empire of the Sun; as well as the photo above of The Hunger Games: Catching ...

Tamika Catchings (@Catchin24) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Tamika Catchings @ Catchin24 ...

Thread: Catching up on OPML & RSS stuff.
Lots of things happening in the Land of OPML these days. 1. At first I thought I wouldn't be able to provide full text descriptions and good ...

The Hunger Games: Catching Fire (2013 movie) : How did past experiences prepare Director Francis Lawrence ...
Answer: I’m really thankful I had been through the fast turnaround process with I Am Legend, which really helped me this time around. When Lionsgate ...

Hunger Games: Catching Fire - Panem Run on the App Store on iTunes
Get Hunger Games: Catching Fire - Panem Run on the App Store. See screenshots and ratings, and read customer reviews.


YouTube - Catching Fire Teaser, Rebel Wilson and MTV Movie Awards Best Moments - ENTV
Veröffentlicht am 15.04.2013 Best Moments from the 2013 MTV Movie Awards feat Catching Fire, Pitch Perfect, Aubrey Plaza drunk, Rebel Wilson, ...

Q&A: Catching up with EDM star Dannic
Dutch big room EDM star Dannic is making waves, both for his collaborations with friends such as Hardwell and Dyro, and his own massive productions. ...

JKim shows KRudd a thing or two about catching the lens
The campaign trail is strewn with landmines for the unwary, but Kevin Rudd could hardly have predicted a visit to a church could end in him being ...

Resources last updated: 1/11/2016 5:13:08 PM