This is a migrated thread and some comments may be shown as answers.

RadNumericTextBox and French Culture

20 Answers 565 Views
Input
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 2
Jeff asked on 17 Jun 2010, 02:17 PM
We use rad numeric text boxes in a web application that switches culture based on the user.
Everything works fine except the key under the 3 on the keypad is a point "."  and the rad numeric textbox won't take it as the decimal separator (comma in French) when the culture if in French.  I have been shown that in Excel it switches it to a comma.  Everything else related to the other Rad Controls react exactly as expected in the French culture. Does anyone have any recommendations on how to deal with this?
Any suggestions would be greatly appreciated.
Thanks,
Jeff

20 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 17 Jun 2010, 02:37 PM
Hello Jeff,

Users who want to use the numeric keypad's decimal separator, should activate a keyboard layout from a country, which uses comma as a decimal separator, e.g. a French keyboard layout (in the Windows Regional Settings).

Greetings,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jeff
Top achievements
Rank 2
answered on 17 Jun 2010, 02:48 PM
Thanks for the quit response.
I did that but it still maps the key under the number 3 in the keypad to a point and not a comma (which the numeric text box rejects because it isn't a comma).  I've thought about just changing the comma separator in all of the numeric text boxes, but there are probably 50 or so and I'm not sure on how I would handle the numeric columns in the rad grid.  It is an odd issue because there are users in England and Germany and everything works fine.
Thanks again.
Jeff
0
Dimo
Telerik team
answered on 17 Jun 2010, 03:27 PM
Hi Jeff,

I am not sure why this happens, but if you use a German keyboard layout, the numeric keypad's decimal separator is a comma. If you use a French (France) one, it is a point. Both cultures should use a comma. For example, the French (Belgium) keyboard layout uses a comma as expected.

In any case, this is a matter of a computer configuration. You can make RadNumericTextBox change commas to dots (or vice-versa) on the fly like this:

http://www.telerik.com/community/forums/aspnet-ajax/input/numerictextbox-with-german-keyboard.aspx#852428

Greetings,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Marcos
Top achievements
Rank 1
answered on 03 Nov 2010, 05:34 PM
Hi,

We have been testing too the RadNumericTextBox and we are experiencing the same issues stated before with a Spanish(spain)  regional configuration. This configuration has the comma as decimal separator, same as French(France) and we have found the same problem as the "." in the keypad is not recognized as the comma would do.

I guess that if this is working right in another cultures (German for example), it should be working too with French or Spanish. Could this be, then, a radnumerictextbox specific issue? (And not one based on the machine configuration).

Best regards.
0
Dimo
Telerik team
answered on 03 Nov 2010, 05:48 PM
Hi Jose,

>> "Could this be, then, a radnumerictextbox specific issue? (And not one based on the machine configuration)."

Add an asp:TextBox to a web page and try pressing the numeric keypad's decimal deparator key. Does it produce the expected decimal sepator for the selected keyboard layout (and for the selected RadNumericTextBox culture) ?

Regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Marcos
Top achievements
Rank 1
answered on 03 Nov 2010, 06:15 PM
Hi,

I have tested what you said and it does not appear the decimal separator expected. What does this mean?
0
Dimo
Telerik team
answered on 03 Nov 2010, 06:23 PM
Hello Jose,

Frankly speaking, I don't know. It could be that the keyboard layout is not correct, or there are some regional settings, which override it.

Regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jeff
Top achievements
Rank 2
answered on 03 Nov 2010, 06:37 PM
Hi Jose,
I had to come up with a unusual fix in our system to fix this for our France problem.
It is in VB and is in our global.asax page, Lang is a profile setting in the web.config and is set to the culture (fr-FR,en-GB, etc.)
Essentially this puts in a script on every page that swaps out the key as expected in the culture.  We haven't had any unexpected consequences and it only affect the "." in the keypad.
I'm not sure if this is the best way but it solved the problem for me.
Hope this helps,
Jeff
  
Protected Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As System.EventArgs)
        If TypeOf (Context.Handler) Is IRequiresSessionState Or TypeOf (Context.Handler) Is IReadOnlySessionState Then
            Dim p As Page = TryCast(HttpContext.Current.Handler, Page)
            If p IsNot Nothing Then
                Dim pb As ProfileCommon = DirectCast(HttpContext.Current.Profile, ProfileCommon)
                If pb IsNot Nothing Then
                    System.Threading.Thread.CurrentThread.CurrentUICulture = New CultureInfo(pb.Lang)
                    System.Threading.Thread.CurrentThread.CurrentCulture = New CultureInfo(pb.Lang)
                    If pb.Lang.Contains("fr") Then
                        Dim str As String = "document.onkeydown=globalKeydown;function globalKeydown(ev){ev ||(ev=window.event);var keyCode =(ev.keyCode?ev.keyCode:(ev.charCode?ev.charCode:ev.which));var currentElement =(ev.target||ev.srcElement);if(keyCode==110){var t=setTimeout('swapDecimal(\''+currentElement.id+'\');',10);return false;}}function swapDecimal(field){if(document.selection){document.getElementById(field).focus();sel=document.selection.createRange();sel.text=',';}else if(document.getElementById(field).selectionStart||document.getElementById(field).selectionStart=='0'){var startPos=document.getElementById(field).selectionStart;var endPos=document.getElementById(field).selectionEnd;document.getElementById(field).value=document.getElementById(field).value.substring(0,startPos)+ ','+document.getElementById(field).value.substring(endPos,document.getElementById(field).value.length);}else{document.getElementById(field).value += ',';}}"
                        p.ClientScript.RegisterClientScriptBlock(p.GetType, "GlobalKeyDown", str, True)
                    End If
                       
                End If
            End If
        End If
    End Sub
0
Jean-Yves
Top achievements
Rank 1
answered on 20 Jan 2011, 08:54 AM
Hello Jeff, 

Your solution look just perfect!!! It affect all the application and stuff so it's perfect.

BUT, (yes there is a but... :p) it's not working on Google Chrome. Do you have an idea why ? 

Do you have a solution cross browser? 

Thank you

Jean-Yves

PS: It's working on IE8 and FireFox
0
Jeff
Top achievements
Rank 2
answered on 20 Jan 2011, 01:41 PM
Hi Jean-Yves,
We haven't experienced this issue mainly because Chrome isn't approved for our customer's users (for other reason not this particular one).
I have tested it on our pages though and it seems to work.  Do you show any errors in the javascript on the page (under tools --> Javascript console)?  Also I am testing version 8.0.552.237 if that makes a difference.
Best Regards,
Jeff
0
Jean-Yves
Top achievements
Rank 1
answered on 20 Jan 2011, 05:22 PM
Hello, 

I just looked on the console and here is the error : 

Uncaught TypeError: Object #<a KeyboardEvent> has no method 'initKeyEvent'
Telerik.Web.UI.RadNumericTextBox._triggerDecimalSeparatorPressedEvent
Telerik.Web.UI.RadNumericTextBox._onTextBoxKeyDownHandler
 (anonymous function)
 
aspnet-scripts.telerikstatic.com/ajaxz/2010.3.1317/Input/NumericTextBox/RadNumericInputScript.js:212
aspnet-scripts.telerikstatic.com/ajaxz/2010.3.1317/Input/NumericTextBox/RadNumericInputScript.js:205


May be you have an idea

Thank you :)
0
Jeff
Top achievements
Rank 2
answered on 20 Jan 2011, 08:43 PM
Hi,
This error seems to be generating from the telerik controls, although I'm not completely sure. 
Did you need to modify what I supplied at all?  If so can you post it?
Thanks,
Jeff
0
Jean-Yves
Top achievements
Rank 1
answered on 21 Jan 2011, 01:47 PM
Hello, 

So, my code is in C#... But it's the same thing...
protected void Application_PreRequestHandlerExecute(object sender, System.EventArgs e)
        {
            if ((Context.Handler) is IRequiresSessionState | (Context.Handler) is IReadOnlySessionState)
            {
                var p = HttpContext.Current.Handler as Page;
                if (p != null)
                {
                    var lang = Thread.CurrentThread.CurrentUICulture.Name;
                    if (lang != null)
                    {
                        if (lang.Contains("fr"))
                        {
                            const string str = "document.onkeydown=globalKeydown;function globalKeydown(ev){ev ||(ev=window.event);var keyCode =(ev.keyCode?ev.keyCode:(ev.charCode?ev.charCode:ev.which));var currentElement =(ev.target||ev.srcElement);if(keyCode==110){var t=setTimeout('swapDecimal(\\''+currentElement.id+'\\');',10);return false;}}function swapDecimal(field){if(document.selection){document.getElementById(field).focus();sel=document.selection.createRange();sel.text=',';}else if(document.getElementById(field).selectionStart||document.getElementById(field).selectionStart=='0'){var startPos=document.getElementById(field).selectionStart;var endPos=document.getElementById(field).selectionEnd;document.getElementById(field).value=document.getElementById(field).value.substring(0,startPos)+ ','+document.getElementById(field).value.substring(endPos,document.getElementById(field).value.length);}else{document.getElementById(field).value += ',';}}";
                            p.ClientScript.RegisterClientScriptBlock(p.GetType(), "GlobalKeyDown", str, true);
                        }
                    }
                }
            }
        }

And on my page I have a (RadNumericTextBox with type="Currency")
<telerik:RadNumericTextBox ID="RadNumericMontantAffaire" runat="server"
                                            DbValue='<%# Bind("MontantAffaire") %>' EmptyMessage="Obligatoire !" EmptyMessageStyle-BackColor="Red" Type="Currency" />

The dot in the numeicPad is working perfectelly on : IE6, 8 and firefox. But not on Google chrome.

In fact, i'have put a alert(keycode) to test what is wrrong on Google chrome. And the problem is here most probably, because each key of the keyboard return a value (in the alert) exept on the dot... Nothing happen...

It's wirred!

Do you have any ideas to make it work everywhere?

Thank you
0
Jeff
Top achievements
Rank 2
answered on 24 Jan 2011, 02:17 PM
Jean-Yves,
I don't see anything wrong with your code and when we test ours it seems to work (although we don't use chrome extensively).
Maybe one of the Telerik guys can offer a suggestion.
Sorry I can't be of more help.
Jeff
0
Martin
Telerik team
answered on 26 Jan 2011, 09:42 AM
Hello Guys,

Could you please verify whether your code works as expected with a standard text box under Chrome? If no errors are generated, I would suggest that you open a formal support ticket and send me a small runnable sample that I can test locally. This way I will be able to provide you with more to the point resolution.

Regards,
Martin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Jean-Yves
Top achievements
Rank 1
answered on 26 Jan 2011, 06:49 PM
Hello and OURA OURA !!!

I found somthing witch is working everywhere (At least I Think)
So, I tested with different options. I put
  • The code in the global.asax
  • Different textBox in the page.
  • Each possibility of Region and Language options : ',' or '.'
This is my ASPX :

<table style="width:400px; margin-left:auto; margin-right:auto; text-align:left" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <th>
                   TextBox
                </th>
                <td>
                    <asp:TextBox ID="TextBox" runat="server" />
                </td>
            </tr>
            <tr>
                <th>
                   RadNumericTextBox Empty
                </th>
                <td>
                    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server"></telerik:RadNumericTextBox>
                </td>
            </tr>
            <tr>
                <th>
                   RadNumericTextBox Currency
                </th>
                <td>
                    <telerik:RadNumericTextBox ID="RadNumericTextBox2" runat="server" Type="Currency" Culture="fr"></telerik:RadNumericTextBox>
                </td>
            </tr>
            <tr>
                <th>
                   RadNumericTextBox Number
                </th>
                <td>
                    <telerik:RadNumericTextBox ID="RadNumericTextBox3" runat="server" Type="Number" Culture="fr"></telerik:RadNumericTextBox>
                </td>
            </tr>
            <tr>
                <th>
                   RadNumericTextBox Percent
                </th>
                <td>
                    <telerik:RadNumericTextBox ID="RadNumericTextBox4" runat="server" Type="Percent" Culture="fr"></telerik:RadNumericTextBox>
                </td>
            </tr>
        </table>


And in fact, every situation is working perfectly with the dot on the numeric keypad exept the RadNumericBox Empty where their is no 'type'.

So with:
  • The TYPE
  • The culture
  • The global.asax
It's perfect !!!

May be you can integrate this automatically without the global.asax?

Thank you :)

Jean-Yves
0
Martin
Telerik team
answered on 01 Feb 2011, 08:05 AM
Hello Jeff Sager,

I have performed some further testing of your markup code and noticed that when a French keyboard layout is selected, the "." (dot) key from the number keypad actually types "." (dot) char instead of "," (coma). You can easily verify this by changing your keyboard layout to French, open a notepad file and press the "." (dot) key from the number keypad. Since the French culture implemented in .NET has its decimal separators set to "," (coma) hence the problem - RadNumericTextBox expects "," (coma), but receives "." (dot) from the keyboard. The same scenario works as expected for German and Bulgarian keyboard layouts which type the correct decimal separators corresponding to the relevant .NET cultures.

Based on the above, it looks like the problem is specific to the French keyboard layout. Running your code (without the global.asax hack) with a Bulgarian or German keyboard layouts works as expected on my side. That is why I would suggest that you keep the French culture setting of your RadNumericTextBox controls, but choose a keyboard layout that submits the correct character from its number keypad.

I hope this helps.

Best wishes,
Martin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Jesús
Top achievements
Rank 1
answered on 29 Mar 2011, 05:21 PM
We have the same problem in Spanish keyboard.

In a customer is using ancient Telerik controls (latest version of 2008), this problem doesn't exists.

Any easyly way to solve this?
0
Martin
Telerik team
answered on 01 Apr 2011, 03:54 PM
Hello El senyor dels Bertins,

The problem with Spanish culture is exactly the same as with the French one - when spanish keyboard layout is used the key of the numpad supplies "." (dot) character, while the Spanish culture in .NET expects "," (coma) as decimal separator.

As to the fact that the Q3 2008 version handles the above scenario - there was some incorrect code implemented in this version that seemingly worked. However, it handled only the case where "." (dot) is supplied from the keyboard. Our developers considered this behavior not correct and fixed it by using the control's culture decimal separator instead.

Since the issue is not connected to RadControls and is out of Telerik support scope, you will have to implement custom logic that detects the typed character and substitute it with the correct one according to the control's culture. My colleague Dimo has already proposed this workaround in an earlier post of this thread.

I hope this helps.

Greetings,
Martin
the Telerik team
0
Stefano
Top achievements
Rank 1
answered on 17 Jun 2011, 09:16 PM
I had the same problem with Italian culture. I finally solved this way:

    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server">
      <NumberFormat DecimalSeparator=","/>
      <ClientEvents OnKeyPress="OnKeyPress" />
   </telerik:RadNumericTextBox>
        
    <script type="text/javascript">
        function OnKeyPress(sender, eventArgs) {
            if (eventArgs.get_keyCharacter() == ".") {
                eventArgs.set_cancel(true);
                if (sender._textBoxElement.value.indexOf(",") < 0)
                    sender._textBoxElement.value = sender._textBoxElement.value.replace(".", "") + ",";
            }
        }
    </script>
Tags
Input
Asked by
Jeff
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Jeff
Top achievements
Rank 2
Marcos
Top achievements
Rank 1
Jean-Yves
Top achievements
Rank 1
Martin
Telerik team
Jesús
Top achievements
Rank 1
Stefano
Top achievements
Rank 1
Share this question
or