Hi,
Is there any way (besides placing controls in UpdatePanel) to change WebCurrencyEdit culture on the client? I'd like to change culture based on user's choice from DropDownList without (visible) server rountrip. In fact i only need to display correct currency symbol in non-edit mode. Is there any way to achieve that?
Best Regards,
Peter R
Hi Peter,
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$" onclick="changeSymbol()" /><igtxt:WebCurrencyEdit ID="WebCurrencyEdit1" runat="server"></igtxt:WebCurrencyEdit>
Did you check this solution in VS 2008,,,,,,,,Its not working there........
Hi Yasser,
Is it possible to provide a simple sample to reproduce "Its not working there...".I tried following in VS2008 and it worked as expected.
aspx:
<igtxt:WebCurrencyEdit ID="WebCurrencyEdit1" runat="server" ValueText="12"></igtxt:WebCurrencyEdit><asp:Button ID="Button1" runat="server" Text="Button" onclick="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.