Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 IP address text box

Author  Topic 

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-09-29 : 14:32:22
I need to create four little text boxes that as soon as user enters number to first one it should know and cursor moves second box.. and third and fourth. Only thing when I am collecting data from those text boxes how to place them in sql table, because I have only one column for IP adress? Or is it any other way to do that?

IP address format xxx.xxx.x.x

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-29 : 15:22:48
use a regular expression on one texbox validation event. that way you won't have any problems.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-09-29 : 15:49:11
+1 to the single textbox


<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-09-29 : 18:01:56
can you guys be more specific, I will be doing this first time.
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-09-29 : 19:13:42
Someone had to have done it before..

http://www.codeproject.com/cs/miscctrl/IpAddrCtrlLib.asp

give codeproject a search for that kind of thing, there are several hits.
I would probably just go for a single textbox and validate the input with regex or such.
Regex is a bit tricky to get the hang of, and I'm still not there, but this is pretty basic stuff.

I bet if you google "ip adress regex"...

From your example in sql:
select patindex('[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9].[0-9]','123.123.1.1') > 0
gives a valid input.
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-09-29 : 19:45:40
do I need to mess with .. this stuff, can I just use validation code easier, as soon as first text box full, make cursor to jump next text box?
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-09-29 : 19:53:57
Or just use 1 text box and validate the input.
This is ASP.NET right, how do you make the cursor jump from one control to another ?
java/vb-script ?
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-30 : 05:29:00
http://www.regexlib.com
search for ip address and you'll get a bunch of regex's to use.
go with one textbox. trust me it's less hassle.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

notsosuper
Posting Yak Master

190 Posts

Posted - 2005-09-30 : 12:12:16
Hey Guys, I did figure out without dealing with that stuff, all I needed is set the value of all text boxes as string for sql, and for jumping from one text to another , I needed to add javascript function. That's it!
Thanks for trying to help anyway..
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-30 : 13:46:21
emm why a javascript function?
simply set the tabindex 1 to 4 for textboxes and you can move between them normaly with a tab.
you save yourself coding the forward and backward movements.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-09-30 : 14:17:27
The javascript stuff is fine if the user doesn't make a typo, but oftentimes that code doesn't allow them to "go back" and change one numebr easily.

The single text box with a regular expression validator is the way to go here IMHO.

Michael

<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>
Go to Top of Page
   

- Advertisement -