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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

MaskedEditExtender, text removed if you lose focus and set focus back on textbox

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net

I have a MaskedEditExtender with Mask="(999) 999-9999".

Now my problem is, if someone goes into the textbox and enters


Then they leave the textbox, and then see that they forgot to enter the area code, if they go back in there to enter the area code, it starts overwritting the other numbers instead of just adding to them. 

View Complete Post

More Related Resource Links

how to check avaibility for user name as soon as text box lose his focus


hi friends,

i am developing web portal and i need to know, how do check user name is available or not in database as soon as textbox lose focus,

i have problem, how to go code behind page after textbox lose his focus.

thanx in advance. 

MaskedEditExtender Gets Focus on Postback

I'm having a really strange issue with the MaskedEditExtnder. I've attached some markup for one of the textboxes. I'm using a MaskedEditExtender and MaskedEditValidator along with a CalendarExtender so the user has the option to type the date or click on an image and pick the date. So, if I enter/pick a date then select a control that forces a postback (usually a dropdownlist but not always) when the page is returned the focus goes back to the textbox I just entered the date in. So what about the MaskedEdit, MaskedEditValidator, CalendarExtender would cause the page to return focus to the control being extended? See markup below - am I missing something??  <asp:TextBox ID="txtEffectiveDate" runat="server" Width="100px" CssClass="textbox" AutoCompleteType="Disabled" Font-Bold="True"/> <asp:ImageButton ID="ImgBtnCalc1" runat="server" ImageUrl="~/images/Calendar_scheduleHS.png" CausesValidation="False"/> <cc1:MaskedEditExtender ID="txtEffectiveDate_MaskedEditExtender" runat="server" Enabled="True" TargetControlID="txtEffectiveDate" Mask="99/99/9999" MaskType=&qu

How come I can't set focus to a textbox in DetailsView?

Here's the first part of a DetailsView control definition:          <asp:DetailsView ID="DetailsView1" runat="server" DefaultMode="Edit" AutoGenerateRows="False" Width="100%" BorderColor="Silver">            <RowStyle Height="25px" />            <Fields>              <asp:TemplateField HeaderText="Name" SortExpression="Name">                <EditItemTemplate>                  <asp:TextBox ID="textBoxName" runat="server" Text='<%# Bind("Name") %>' CssClass="detailsTextBox" onclick="SelectText2(this)" onKeyUp="EnableSubmit()" />                </EditItemTemplate>                <InsertItemTemplate>        &nb

why isnt the focus being set to a textbox in the gridview?

Hi, i have a gridview with textboxes in. a barcode reader is used to enter data in the textboxes in the grid. when something is scanned in the page does a full postback. so after a postback and after something has been scanned in, i want the focus to be moved to the next textbox in the row inside the gridview.  i have some code, but it doesnt seem to work. after the postback the focus is set to one of the textboxes outside the grid. i need it to recognise one of the textboxes in the grid. i have tried to use the findcontrol property to do this still doesnt work. please can anyone see where i am going wrong. what i wanted to do is for it to automatically tab to the next textbs in the gridview after a postback. please any advise on this would be much appreciated. thank you very muchprotected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { WebControl wcICausedPostBack = (WebControl)GetControlThatCausedPostBack(sender as Page); int indx = wcICausedPostBack.TabIndex; var ctrl = from control in wcICausedPostBack.Parent.Controls.OfType<WebControl>() where control.TabIndex > indx select control; ctrl.DefaultIfEmpty(wcICausedPostBack).First().Focus(); } } protected Control GetControlThatCausedPostBack(Page page)

MaskedEditExtender looses format when not in focus


I have a tex box which I'm using to capture a bank sort code.

I want to use the AJAX MaskedEditExtender so the user only ever inputs the data in this format 12-34-56.

Here is my extender code:

<asp:MaskedEditExtender ID="mexSortCode" runat="server" TargetControlID="txtSortCode"
                                    Mask="99-99-99" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus"
                                    OnInvalidCssClass="MaskedEditError" InputDirection="LeftToRight"
                                    AcceptNegative="Left" ErrorTooltipEnabled="True" />

This initially works fine, however when i remove the focus on this text box the input removes any hyphen and the texbox value is left like this 123456.

Does anyone know a way which i can maintain the input?

Many thanks

textbox focus problem


I have a textbox (txtMaiden) and a radio button list (rblGender) in two separate User Controls that I'm using for a registration site. The txtMaiden control appears or disappears depending on whether Male or Female is designated on the radio button. This all works fine but I want the textbox to have focus when it becomes visible. As of now, it only gets focus when the page refreshes. Code follows. Any ideas?

<Prf:gender ID="GenderE" Gender='<%#Bind("Gender")%>' runat="server" />
<Prf:maiden ID="MaidenE" Maiden='<%#Bind("MaidenName")%>' Maiden_Disp='<%#Bind("MaidenName_Disp")%>'
    runat="server" />

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="gender.ascx.vb" Inherits="userControls_profile_gender" %>
<asp:Panel ID="pnlGender" Visible="true" runat="server">
    <div class="label">
        <asp:Label ID="lblGender" Text="Sex:" runat="server" />
    <div class="ctrl">
                <asp:RadioButtonList ID="rblGender" AppendDataBoundItems="True" AutoPostBack="True"

keep focus on textbox on textchange event



How can I keep focus on caller textbox on textchange event or set focus on a given textbox according to a given value?

How can I know which textbox triggered the event if I need to use the same textchange method?

thanks in advance

Silverlight - Textbox on focus wait till a Asynchronous process is complete



I have a textbox, where i call its lostfocus event when the value changes.

In lost focus i do a Asynchronous process to update a grid with the text entered. 

I have a scenario in which immediately after changing the value in textbox i hit a button, though the button click event raises i want it to wait till the asysnchronous process in lost focus of the textbox is complete. i want to do this as i use the result from lostfocus in button click event.

Please let mt know if there is a way to make the lost focus wait till it completes the asynchronous call.



codebehind set focus textbox field in ajaxtoolkit : Tab


Hi all ,

I am stuck in the set focus field in field in ajaxtoolkit : Tab  at codebehind when button click.

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

    If StringUtil.IsStringEmpty(Me.ddlSex.SelectedValue) = True Then

       Page.ClientScript.RegisterStartupScript(Me.GetType, "ErrMsg", 
            JScriptUtil.ErrorMsg("Jantina (Sex): "

    End if

   End Sub

How to prevent Loss of Focus if there is Validation error on a textBox?

Hi i have a TextBox displayed as a TreeViewItem and when the user enters text and Tabs away or clicks somewhere else i want the control to retain focus if there is any validation error.Is there anyway i can do that? I am adding the ValidationRule to the TextBox created dynamically in code..I do see the default redborder when there is a validation error.I just want to force the user to correct the error and not go anywhere else in the app until its fixed..
Thanks in advance...

How to set focus to UserName textbox in Login Control ?



can you please tell how to focus cursor to UserName TextBox in Login control when page is loaded for the first time in browser ? 

setting focus to a textbox


using vb.net/asp.net 2005

after the user clicks on a button in the buttonClick event I am trying to set the focus at the end of the function simply as follows:


However the focus is instead going to another button.  The tabIndex property is not set on any controls on the page.  Has anyone experience this?  thanks


Set Focus on Textbox


    I have a composite control with Listbox and a Textbox. I am trying to achieve a functionality where in if I type something in the text box, the list box items gets filtered based on the text typed.

   I am able to get this working, however I am having issues in retaining the Keyboard focus in the Textbox.

   I am doing this functionality on the Key Up Event of the Textbox. If I type a text the event handler is getting triggered and performing the operation, but the focus goes from the Textbox

I am forcing the Focus by calling the Focus() function on the Textbox, but it doesn't seem to be working.

 SDK of Focus function says: "Even if an element is focusable and enabled, event handling within a specific tree, (such as for a composite control) might respond to the preview focus events by not allowing focus there, thus this method would return false."

How can I force the focus on the Textbox object.


Text box Lost focus and JSON


I am trying to make below form where I will put phone no text into text box and if it is existing in database then in lost focus corresponding customer name will automatically come in customer name field and if not exits then it should be I will show dialog box for inserting new   record for customer.

Kindly help for some tutorial or some URL which can help me.

How to determine which textbox has focus?



I am trying to set the color of a textbox that has focus to gray. How can I tell which textbox currently has the curser on it so when they click the change color button it will change the textbox that is focused. Something like this:

focusedtextbox.BackColor = Drawing.Color.LightGray



set focus textbox inside modalpopupextender


hi all.

i am working wit modal popup extender where i wan to set focus to a text box in popup.

can any 1 help me out with detail. plz 

abour changing border of textbox when focus textbox


Hi.i try to do this: when mouse come over the textbox, border color will change. When the mouse leave over the textbox, border of text turn the old type. Also, when textbox is focused,  border of textbox color will change. my problem here is focus event. i did mouseover and mouseleave. but i can't do focus event. My codes is below:

$("#txtsearch").mouseover(function ()


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