开发者

Databinding int32 to MaskedEditExtender enabled TextBox

I have a master/detail scheme for editing an asp:GridView using an asp:DetailsView. One of my fields is for a phone number of type int64 (always 10 digits). I would like this field to always be displayed as (###)###-####. My issue is the first digit in the phone number is always truncated for my edit item field which I used a MaskedEditExtender to achieve the formatting.

Here is my EditItemTemplate for the details view:

<cc1:MaskedEditExtender TargetControlID="edtPROJ_Leader_Phone" Mask="(999)999-9999" runat="server" ClearMaskOnLostFocus="false" ClipboardEnabled="true" MaskType="Number" />
<asp:TextBox ID="edtPROJ_Leader_Phone" runat="server" Text='<%# Bind("PROJ_Leader_Phone") %>' ></asp:TextBox>

When my details view is displayed for editing, the text box displays(_23)456-7890 for the integer 1234567890. Also worth noting that if the property 开发者_Python百科MaskType="Number" is removed, the textbox shows: (234)567-890_. I would of course have the textbox show (123)-546-67890 after binding.


Problem could be that you're not using "Escape Characters" for your "(", ")", and "-".

Might want to change your mask from

Mask="(999)999-9999"

to

Mask="\(999\)999\-9999"

According to the documentation, there is no "(", ")", or "-", so you may be telling it to do something unintended. From the section on masks...

/ - Date separator

: - Time separator

. - Decimal separator

, - Thousand separator

\ - Escape character

{ - Initial delimiter for repetition of masks

} - Final delimiter for repetition of masks

Examples

9999999 - Seven numeric characters

99/99 - Four numeric characters separated in the middle by a "/"

http://www.asp.net/ajaxlibrary/act_MaskedEdit.ashx


This issue appears to be a bug related to: http://www.codeplex.com/AjaxControlToolkit/WorkItem/View.aspx?WorkItemId=11819


I had the same issue, and what solved it for me was changing the MaskedEditExtender's property
"ClearMaskOnLostFocus" to True.


I had the same issue too, and :

  1. Doing despecialisation in the mask like :

        Mask="\(999\)999\-9999",
    
  2. With ClearMaskOnLostFocus set to true.

Solved the problem.

Thanks for all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜