C# 向ASPxTextBox添加掩码,以便仅查看值的最后4位数字

C# 向ASPxTextBox添加掩码,以便仅查看值的最后4位数字,c#,asp.net,devexpress,C#,Asp.net,Devexpress,我需要添加一个掩码/DisplayFormatString,以便仅查看项目中引用AccountNumber的所有ASPxTextBox中的最后4位数字。在传递帐号时,有一种返回格式化帐号的常用方法 如何调用此方法,或者是否有简单的方法将此掩码应用于整个项目中的所有AccountNumber AspXtextBox。你能帮我一下吗 示例:如果实际帐号为987654321。然后它应该显示为******4321 <dx:ASPxTextBox ID="txtBankAccountNumber"

我需要添加一个掩码/DisplayFormatString,以便仅查看项目中引用AccountNumber的所有ASPxTextBox中的最后4位数字。在传递帐号时,有一种返回格式化帐号的常用方法

如何调用此方法,或者是否有简单的方法将此掩码应用于整个项目中的所有AccountNumber AspXtextBox。你能帮我一下吗

示例:如果实际帐号为987654321。然后它应该显示为******4321

<dx:ASPxTextBox ID="txtBankAccountNumber" ClientInstanceName="txtBankAccountNumber" runat="server" Width="100%">
</dx:ASPxTextBox>

请检查以下示例以将掩码设置为aspxtbox

e、 g


根据我的经验,您可以通过两种方式进行掩蔽:

1) Devexpress:

您可以使用devexpress,也可以使用带有电话号码等的屏蔽

像这样的代码:

<dx:ASPxTextBox ID="txtPhone" runat="server" Width="100%" ClientInstanceName="clTxtPhone" Caption="Phone Number">
                <MaskSettings Mask="0000" IncludeLiterals="None" />
                <ValidationSettings ErrorDisplayMode="ImageWithTooltip" Display="Dynamic" ErrorTextPosition="Bottom" />
                <ClientSideEvents Init="phone_InitAndKeyUp" KeyUp="phone_InitAndKeyUp" />
            </dx:ASPxTextBox>

2) Javascript: 像这样:

<!DOCTYPE html>
<html>
<head>
<!-- Example jQuery Reference -->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!-- Example jQuery Masking Script -->
<script src="http://digitalbush.com/wp-content/uploads/2013/01/jquery.maskedinput-1.3.1.min_.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
  <script type='text/javascript'>
    $(function(){
        // Define your mask (using 9 to denote any digit)
        $('#YourTextBox').mask('(999) 999-9999');
    });
  </script>
</head>
<body>
    <!-- Example of your TextBox -->
    <asp:TextBox ID="YourTextBox" runat="server"></asp:TextBox>
</body>
</html>

JS-Bin
$(函数(){
//定义掩码(使用9表示任何数字)
$('#YourTextBox')。掩码('(999)999-9999');
});

请不要发布重复的问题!屏蔽核心与上面的dupe链接基本相同,但使用不同的事件处理程序:在
aspxtbox
中,您可以尝试
TextChanged
事件(请注意,显示的字符串不得更改其值)。同时添加
以隐藏掩码占位符。
<!DOCTYPE html>
<html>
<head>
<!-- Example jQuery Reference -->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!-- Example jQuery Masking Script -->
<script src="http://digitalbush.com/wp-content/uploads/2013/01/jquery.maskedinput-1.3.1.min_.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
  <script type='text/javascript'>
    $(function(){
        // Define your mask (using 9 to denote any digit)
        $('#YourTextBox').mask('(999) 999-9999');
    });
  </script>
</head>
<body>
    <!-- Example of your TextBox -->
    <asp:TextBox ID="YourTextBox" runat="server"></asp:TextBox>
</body>
</html>