`

开发中货币样式看似简单,没弄过的往往花费比较长时间,本人处理了,贴出来大家分享,也方便自己以后查用

 
阅读更多
开发中货币样式看似简单,没弄过的往往花费比较长时间,本人处理了,贴出来大家分享,也方便自己以后查用     
1.TextBox,绑定值处理
protected void tbxPromisePaymentCollection_TextChanged(object sender, EventArgs e)
        {
            TextBox t = (TextBox)sender;
            if (string.IsNullOrEmpty(t.Text.Trim()))
                return;
            t.Text = Convert.ToDecimal(t.Text.Trim()).ToString("N");
        }
2.只允许数字值限制用JS
  前端调用
<asp:TextBox ID="tbxPromisePaymentCollection" runat="server" Style="font-style: italic;
        background-color: yellow;" Text='<%# Bind("MonthPromisePC") %>' Width="104px"
        onkeyup="if(isNaN(value))execCommand('undo')"
     onafterpaste="if(isNaN(value))execCommand('undo')" ontextchanged="tbxPromisePaymentCollection_TextChanged"
       ></asp:TextBox>
  js:
主要是调用Javascript自带的两个函数
isNaN(value),execCommand('undo')
0
8
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics