Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2006, 01:36 AM
Friend of Wrox
 
Join Date: Feb 2006
Location: , , USA.
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Default trying to make a custom label for phone numbers...

I would like to make a custom control for phone numbers but I'm not quite sure how to do this. I'm a C# man myself by my new employer likes the VB flavor, so I'm pretty new to this whole VB side of things.

I want a phone number label that displays a formatted phone number. Currently in the databases they tend to store formatting with the numbers, which is ghetto. I want the presentation tier to provide all formatting in our future apps and I want to pull all of that formatted trash out of our databases.

So I guess for this one I'd like the format to look something like:

+1 (999) 999-9999

If there were no country prefix I want it to just display:

(999) 999-9999

If there is an extension I want it to show that too:

(999) 999-9999 Ext. 999

Or whatever.

All I have so far is my properties. Would I overload the Text property in the parent class?

In our database we typically store the area code, and number together. So the text that would be bound to this control would typically be a ten character string of numbers. So that confuses me. I can bind the country prefix to a new property I made called countryPrefix because thats stored in its own column in the database. Same goes for the extension number (in most cases). However the area code, and 7-digit number are typically stoted in one column in the database. So I cant just bind that to any one property because its really three properties....

I might be just over complicating this. Any advice or help anyone could provide would be greatly appreciated!


Code:
Imports Microsoft.VisualBasic

Public Class PhoneNumberTextBox
    Inherits System.Web.UI.WebControls.Label

    Private _countryPrefix As String
    Private _areaCode As String
    ' In a telephone network the first three numbers of what we typically 
    ' refer to as a "telephone number", is called the "exchange number"
    Private _exchangeNumber As String
    Private _customerNumber As String
    Private _extensionNumber As String

    Public Property countryPrefix()
        Get
            Return _countryPrefix
        End Get
        Set(ByVal value)
            _countryPrefix = value
        End Set
    End Property

    Public Property areaCode()
        Get
            Return _areaCode
        End Get
        Set(ByVal value)
            _areaCode = value
        End Set
    End Property

    Public Property exchangeNumber()
        Get
            Return _exchangeNumber
        End Get
        Set(ByVal value)
            _exchangeNumber = value
        End Set
    End Property

    Public Property customerNumber()
        Get
            Return _customerNumber
        End Get
        Set(ByVal value)
            _customerNumber = value
        End Set
    End Property

    Public Property extensionNumber()
        Get
            Return _extensionNumber
        End Get
        Set(ByVal value)
            _extensionNumber = value
        End Set
    End Property

End Class
Neil Timmerman
Programmer II
School of Medicine
University of Missouri Columbia
  #2 (permalink)  
Old August 22nd, 2006, 05:38 PM
Authorized User
Points: 333, Level: 6
Points: 333, Level: 6 Points: 333, Level: 6 Points: 333, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Fresno, California, USA.
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't really haave the answer for you as I am a C++ and C# man too. I can read VB though hehe. I am just posting to ask why your boss is making you go VB when in the world of .NET it doesn't matter. I work with 2 VB guys on stuff. They write in their language, I write in mine but it all comes together nicely as long as my calls to their stuff follows their rules. You can mix the different languages in one ASPX file but you can have different language apsx files work together just don't try and use include statements in apsx files that are not in the same language as the included file. You may already know all this already hehe. He's your boss though. My boss allows our native language as long as it is .NET hehe.

  #3 (permalink)  
Old August 22nd, 2006, 06:07 PM
Friend of Wrox
 
Join Date: Feb 2006
Location: , , USA.
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You know that, and I know that, and I told my boss, so he knows that...despite this, they want VB...I'm going to keep working on them. I do want to learn more languages anyway, so I am ok with it. I accepted the job knowing they wanted me to learn VB and VBScript.

That being said, in my opinion, VB produces less readable code, and the lack of semi-colons to end lines is rediculous. It's also very odd that strings can't be null or something?

Neil Timmerman
Programmer II
School of Medicine
University of Missouri Columbia
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expression for phone numbers [both U.S. an kamii47 BOOK: Beginning Regular Expressions 0 September 8th, 2007 03:08 AM
Removing Blank Spaces in Phone Numbers Brendan Bartley Access 1 April 12th, 2007 11:42 AM
formatting phone numbers xslt_student XSLT 0 August 7th, 2006 04:10 PM
How do you make a label visible in a form Brian263 Access 2 March 19th, 2004 03:32 PM
U.S versus International Phone Numbers bph Access 6 February 19th, 2004 05:15 PM



All times are GMT -4. The time now is 05:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.