数据绑定INT32到MaskedEditExtender启用文本框 [英] Databinding int32 to MaskedEditExtender enabled TextBox

查看:146
本文介绍了数据绑定INT32到MaskedEditExtender启用文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对编辑ASP一个主/详细方案:使用GridView的一个asp:DetailsView控件。我的一个领域是类型的Int64(总10位)的电话号码。我想这个领域总是显示为(###)### - #### 。我的问题是在电话号码中的第一个数字总是截断我的,我用MaskedEditExtender实现格式编辑项目现场。

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.

这是我的EditItemTemplate中的详细信息视图:

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>

当我的详细信息视图显示进行编辑,显示文本框(_ 23)456-7890 的整数1234567890。另外值得一提的是,如果物业被删除MaskType =数字,在文本框中显示:(234)567-890 _ 。当然,我会在文本框中显示(123)-546-67890 后绑定。

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.

推荐答案

问题可能是你不使用转义字符为你(,)和 -

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

可能需要从

Mask="(999)999-9999"

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

: - 时间分隔符

。 - 小数分隔符

, - 千位分隔符

\ - 转义字符

{ - 初始分隔符口罩的重复

{ - Initial delimiter for repetition of masks

} - 最后的分隔符口罩的重复

} - Final delimiter for repetition of masks

范例

9999999 - 7个数字字符

9999999 - Seven numeric characters

99/99 - 通过分离在中间四个数字字符/

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

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

这篇关于数据绑定INT32到MaskedEditExtender启用文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆