netadvantage WebCurrencyEdit动态改变货币显示符号

在网上搜了一大圈,最后在同事的帮助下,找到了个英文网站,问题总算解决了。呵呵!

Solution 1:

You may change symbol and other format properties on client. Below is example to change symbol on client.

Note: You should keep in mind that persistance of those values is not supported and after a postback format will return to original server format.

<script type="text/javascript">
function changeSymbol()
{
  var edit = igedit_getById('<%=WebCurrencyEdit1.ClientID%>');
  var val = edit.getValue();
  edit.symbol = '¥';
  //edit.positivePattern = 'n$';
  //edit.decimalSeparator = ',';
  //edit.groupSeparator = '.';
  edit.setValue(val);
}
</script>
<input type="button" value="Change$" οnclick="changeSymbol()" />
<igtxt:WebCurrencyEdit ID="WebCurrencyEdit1" runat="server"></igtxt:WebCurrencyEdit>


Solution 2:

aspx:

<igtxt:WebCurrencyEdit ID="WebCurrencyEdit1" runat="server" ValueText="12"></igtxt:WebCurrencyEdit>
<asp:Button ID="Button1" runat="server" Text="Button" οnclick="Button1_Click" />

aspx.cs:

protected void Button1_Click(object sender, EventArgs e)
{
 System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
 ci.NumberFormat.CurrencySymbol = "XX";
 this.WebCurrencyEdit1.NumberFormat = ci.NumberFormat;
}

Note: you should keep in mind that changes to Culture do not persist. If you changed something conditionally and that condition is not used for following sessions, then all your conditional custom settings will be lost. If you have another submit button, then after click on that button the "XX" symbol will be lost and default "$" will be used. But that has nothing to do with editor, but with CultureInfo which persistance is not supported by .NET. It means that if you need to customize culture, then you should do that in every single session, for example, within Page.OnLoad event.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值