PDA

View Full Version : [CLOSED] Troubles with some Textfield



timiteh
Nov 25, 2013, 6:35 PM
Hi,

I was testing number formatting with Textfield and the page i was testing is now displaying absolutely nothing.
Here is the code:



<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server"></ext:ResourceManager>
<div>
Champ test: <ext:TextField ID="TextField1" runat="server" MaskRe="=/[0-9\.]/">
<Change Handler="this.setValue(Ext.util.Format.number(newValue.repl ace(/[\$]/g, ''), '0,0.00'));" />
</ext:TextField>
</div>
<div>
Champ asp: <asp:TextBox ID="test" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>


Moreover before it started displaying nothing, the formating was not working at all !

Baidaly
Nov 25, 2013, 11:59 PM
Hello!

You need to use buffer value. You can read more about it here: http://www.ext.net/2012/12/19/introduction-to-ext-net-events/

Try the following one:


<%@ Page Language="C#" %>

<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" SourceFormatting="true" ScriptMode="Debug" />

<div>
Champ test:
<ext:TextField ID="TextField1" runat="server" MaskRe="/[0-9\.]/">
<Listeners>
<Change Handler="this.setRawValue(Ext.util.Format.number(newValue.r eplace(/[\$]/g, ''), '0,0.00')); " Buffer="500" />
</Listeners>
</ext:TextField>
</div>
</form>
</body>
</html>

timiteh
Nov 26, 2013, 3:28 PM
Hi Baidaly,

It works almost as i get strange results when i try to edit the value in the field.
For example if i enter 123456789 i get 123.456.789,00 however when i try to edit the field to remove 9 for example, the field is emptied.
Is it normal ?

Baidaly
Nov 27, 2013, 12:54 AM
OK, I'd use another approach with Focus and Blur:


<%@ Page Language="C#" %>

<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<div>
Champ test:
<ext:TextField ID="TextField1" runat="server" MaskRe="/[0-9\.]/">
<Listeners>
<Blur Handler="
this._value = this.getValue();
this.setValue(Ext.util.Format.number(this.getValue ().replace(/[\$]/g, ''), '0,0.00')); " />
<Focus Handler="
if (this._value != undefined)
this.setValue(this._value); " />
</Listeners>
</ext:TextField>
</div>
</form>
</body>
</html>

timiteh
Nov 27, 2013, 10:07 AM
Thanks Baidali, now it works flawlessly.
Thanks again and take care.