简体   繁体   English

将int32数据绑定到启用MaskedEditExtender的TextBox

[英]Databinding int32 to MaskedEditExtender enabled TextBox

I have a master/detail scheme for editing an asp:GridView using an asp:DetailsView. 我有一个主/详细方案,用于使用asp:DetailsView编辑asp:GridView。 One of my fields is for a phone number of type int64 (always 10 digits). 我的字段之一是int64类型的电话号码(始终为10位数字)。 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. 我的问题是,我的编辑项字段始终使用电话号码的第一位数字截断,而我使用MaskedEditExtender来实现格式化。

Here is my EditItemTemplate for the details view: 这是我的EditItemTemplate的详细信息视图:

<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 MaskType="Number" is removed, the textbox shows: (234)567-890_ . 当显示我的详细信息视图以进行编辑时,文本框显示(_23)456-7890 ,表示整数1234567890。还值得注意的是,如果删除了属性MaskType =“ Number”,则文本框显示: (234)567-890_ I would of course have the textbox show (123)-546-67890 after binding. 绑定后,我当然会有文本框显示(123)-546-67890

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 9999999-七个数字字符

99/99 - Four numeric characters separated in the middle by a "/" 99/99-四个数字字符,中间用“ /”分隔

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

此问题似乎是与以下问题有关的错误: http : //www.codeplex.com/AjaxControlToolkit/WorkItem/View.aspx?WorkItemId=11819

I had the same issue too, and : 我也有同样的问题,并且:

  1. Doing despecialisation in the mask like : 在面具中进行非专业化,例如:

      Mask="\\(999\\)999\\-9999", 
  2. With ClearMaskOnLostFocus set to true. 将ClearMaskOnLostFocus设置为true。

Solved the problem. 解决了问题。

Thanks for all. 谢谢大家

I had the same issue, and what solved it for me was changing the MaskedEditExtender's property 我遇到了同样的问题,为我解决的问题是更改MaskedEditExtender的属性
"ClearMaskOnLostFocus" to True. “ ClearMaskOnLostFocus”改为True。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM