.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Format phone number in asp.net textbox control

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :ASP.Net
Hi,  I have a <asp:textbox> control, I want to display text as a phone number format like phone number mask. Anybody can help on this. Thanks in advance.

View Complete Post

More Related Resource Links

Set contents of textbox when click to call phone number


So I have a text box


li class="textwidth">   
<label class="labelwidth" for="txtLine1">
    Phone #:</label>   
<asp:TextBox ID="txtPhoneNumber" runat="server" Width="202px" onkeydown="javascript:backspacerDOWN(this,event);" onkeyup="javascript:backspacerUP(this,event);" CssClass="inputwidth"></asp:TextBox>

When they click on this or when they click on something by this textbox I want it to call the phone number.

The ACTUAL phone number is filled in the pageload event:

If Not (SPPhone Is Nothing) Then
            Me.txtPhoneNumber.Text = SP.PhoneNumber

I know about the <a href="tel but I don't understand how I can implement it, since I don't know the phone number until the page actually loads.

Thanks for any and all help!

watermark textbox using Ajax control

This is pretty simple compared to jquery. Since we need refer a dll only. we dont want any script for this. we just include that reference into our website.

how to get an array of all the asp.net textbox control inside create user wizard control?



How can I get all the textboxes inside a create user wizard control using getElementsByTagName().

Below is my JQuery code:

<script type="text/javascript">
        function addLoadEvent(func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function() {

        function prepareInputsForHints() {
            var inputs = document.getElementsByTagName("asp:TextBox");
            for (var i = 0; i < inputs.length; i++) {
                inputs[i].onfocus = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
                inputs[i].onblur = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "none";



<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

Composite control: How to bubble a textbox's TextChanged event?


I've created a composite control that contains several controls, including a textbox. I'm trying to expose the TextChanged event of the textbox as an event on the composite control. I understand that events can be bubbled up the control hierarchy and handled at a higher level, which I've attempted to do, but I can't get the bubbled event to fire. When I drop the control on an aspx I can see the TextChanged event, I can subscribe to the event, but nothing ever happens. Any suggestions? Here is what I think is the relevant code:

// My event
private static readonly object EventTextChanged = new object();

//Handle the bubbled event
EventHandler textChangedHandler = (EventHandler)Events[EventTextChanged];

protected override bool OnBubbleEvent(object source, EventArgs e) 
    bool handled = false;

How to format an ItemTemplate value on a gridview control


I have the following in a GridView control:

<asp:TemplateField HeaderText="Count">
         <asp:Label id="lblicount" runat="server" Text='<%# Eval("icount") %>'>

Sometimes the value of this is 0.  I want to display nothing or a blank if the value is 0.  How do I do this?



Creating an integer only textbox control

Hi all I was wondering on how to create an integer only textbox control. Im close I just cant figure out why its not working. public partial class IntegerTextBox : TextBox { public IntegerTextBox() { } private void OnTextChanged(KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar)) e.Handled = true; } }

Getting IMEI number of a mobile phone

I am developing an  asp.net web application which supplies content to mobile phones  , Im trying to get the imei number of  mobile phones using thier numbers. How can we achieve this?

Need help with validating an alphanumeric string within a textbox control.

Hi everyone,I am developing a simple WinForms app for a presentation next week and need to validate that a particular string in a particular textbox is alphanumeric.  I have included the code from the button click event handler below: // Alphanumeric private void btnValidate4_Click(object sender, EventArgs e) { try { if (txtAlphanumeric.Text == "") MessageBox.Show("Please enter an alphanumeric string before clicking the 'Validate' button.", "Whoa there, pardner!!", MessageBoxButtons.OK, MessageBoxIcon.Information); else { Regex rgxAlphanumeric = new Regex("^[a-zA-Z0-9]*$"); Match alphaNumericMatch = rgxAlphanumeric.Match(txtAlphanumeric.Text); if (!alphaNumericMatch.Success) MessageBox.Show("The string supplied does NOT match the specified pattern.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); else { MessageBox.Show("The supplied string matches the specified pattern.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

Datetime format in textbox

Hi I'm retrieving a datetime type of data from sql table databaseMy problem is when I'm retriving it to my textbox it appear something like this -->> 1/10/1990 12:00what i want is to remove the time and appear like this only ---> 1/10/1999 How can I do this?btw I'm using c# Thanks in advance!

Wizard Control textbox data is lost

I'm using a wizard contol with several textbox fields. I have two textbox fields disabled (textbox19 and textbox20)because I don't want the user to change the values that are calculated from the other textboxes (see javascript below). I do this with javascript on the clientside. My problem occurs when the user is in STEP2 and goes back to STEP1 the values in the disabled fields are gone. Is there a way to fix this? I would also like to perform a validation on textbox20 but I haven't been able to do that with the textbox disabled. How can I do validations on a field that is disabled? I've tried enabling the fields and using readonly = true but that doesn't work either. Any suggestions? // Client Side script to do calculations <script type="text/javascript">       function calculateSubTotal() {      var txt6 = document.getElementById('<%= TextBox6.ClientID %>');     var txt12 = document.getElementById('<%= TextBox12.ClientID %>');     var txt18 = document.getElementById('<%= TextBox18.ClientID %>');     var txt14 = document.getElementById('<%= TextBox14.ClientID %>');     var txtSubTotal = document.getElementById('<%= TextBox19.Cl

proper format for number column

Hi  In a column i have number datatype but after filling some no it's giving like that 23,786,23 (mostly like a currency format ) but i need like that 2378623 so give me suggestion how i can implement this in sharepoint 2010 , is there need to bound some column level validation for that ............... 

Is textbox the only control with a multi-line option?

I was trying to use a label control to print out a string with spaces and line feeds, but with no success. Textbox is the only control I have found so far that will print my line feeds (ControlChars.Lf)  However, can I remove the scrollbar from the textbox display that appears when textboxmode is set to multiline? -smc

Possible bug in WebBrowser Control realization in WPF and Windows Phone 7

Hello, I'm tried to make authentication component for russian social network Vkontakte.ru (vk.com). In russian forum nobody answered me. The proplem: When authentication is complete WebBrowser component must be redirected to page like: http://vkontakte.ru/login_success.html#session={%22expire%22%3A%221272008089%22%2C%22mid%22%3A%22100172%22%2C%22secret%22%3A%229c8d8f0305%22%2C%22sid%22%3A%221131703552161ae352a1256402e3140d7cbde41b1602a93d15472c82%22} In Windows Form application all works normal. But in WPF browser was redirected to http://vkontakte.ru/login_success.html Without #session.... It happened not only in WPF Applications, but even in Windows Phone 7. It is a bug? Or this parameter can be accessed from another place?

Report Format RDL Version Control

Hi, I've been using file name with date plus the time stamp as my version control. As my library grow it's getting out of control and there are chances that I mistakenly saved the file over the previous version. What is the best practice and tool for RDL report format version control?

Is there a method that returns the control's type, such as "TextBox", "TextBlock", "Canvas", etc.,

Hello, I have a method that is passed in a FrameworkElement Ctrl.  When I use Ctrl.GetType().ToString() I get "System.Window.Controls.TextBox" or another string if a different type of control is passed in.  All I am interested in is the text after the last dot/period.  In my searching I thought I came across something that just returned the portion I'm looking for, but now can't find it. Is there a method that returns the control's type, such as "TextBox", "TextBlock", "Canvas", etc., without its parents? Regards, Robert

Populate textbox in FormView Control in Edit Mode with querystring

Can someone please tell me what I am doing wrong here. I am simply trying to get a querystring value and pass it to a textbox in a formview with the default view set to edit mode.     Protected Sub fv_Detach_Engine_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles fv_Detach_Engine.DataBound        If fv_Detach_Engine.CurrentMode = FormViewMode.Edit Then            Dim tbx_IDProfileAccount As TextBox = TryCast(fv_Detach_Engine.FindControl("tbx_IDProfileAccount"), TextBox)            If tbx_IDProfileAccount Is Nothing Then                tbx_IDProfileAccount.Text = Request.QueryString("IDProfileAccount")            End If        End If    End Sub  

format-number issues with the Data View Web Part in SharePoint 2010

I have a number column named @Year_x0020_1_x0020_Revenue in the data view web part in SharePoint Designer 2010. In the Xpath expression builder - @Year_x0020_1_x0020_Revenue previews "500,000" If I use the format-number in the Xpath expression builder ==> format-number(@Year_x0020_1_x0020_Revenue, '$#,##0.00;-$#,##0.00'), it returns NaN. Is there any reason? 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend