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

发布于 2024-08-24 11:45:30 字数 781 浏览 3 评论 0原文

我有一个使用 asp:DetailsView 编辑 asp:GridView 的主/详细方案。我的字段之一是 int64 类型的电话号码(始终为 10 位数字)。我希望此字段始终显示为 (###)###-####。我的问题是电话号码中的第一个数字总是在我的编辑项目字段中被截断,我使用 MaskedEditExtender 来实现格式化。

这是我的详细信息视图的 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>

当显示我的详细信息视图进行编辑时,文本框会显示整数 1234567890 的(_23)456-7890。还值得注意的是,如果删除属性 MaskType="Number",则文本框会显示: <代码>(234)567-890_。我当然会让文本框在绑定后显示 (123)-546-67890

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 MaskType="Number" is removed, the textbox shows: (234)567-890_. I would of course have the textbox show (123)-546-67890 after binding.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

两个我 2024-08-31 11:45:30

问题可能是您没有为“(”、“)”和“-”使用“转义字符”。

可能想要将您的掩码从 更改为

Mask="(999)999-9999"

根据

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

文档,没有“(”、“)”或“-”,因此您可能会告诉它做一些意想不到的事情。从关于掩码的部分...

/ - 日期分隔符

: - 时间分隔符

。 - 小数分隔符

, - 千位分隔符

\ - 转义字符

{ - 掩码重复的初始分隔符

} - 掩码重复的最终分隔符

示例

9999999 - 七个数字字符

99/99 - 四个数字字符中间用“/”分隔

< a href="http://www.asp.net/ajaxlibrary/act_MaskedEdit.ashx" rel="nofollow">http://www.asp.net/ajaxlibrary/act_MaskedEdit.ashx

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

°如果伤别离去 2024-08-31 11:45:30

我遇到了同样的问题,为我解决的方法是更改​​ MaskedEditExtender 的属性
“ClearMaskOnLostFocus”为 True。

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

旧人 2024-08-31 11:45:30

我也遇到了同样的问题,并且:

  1. 在面具中进行去专业化,例如:

     掩码=“\(999\)999\-9999”,
    
  2. 将 ClearMaskOnLostFocus 设置为 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文