[CLOSED] Read Only NumberField

  1. #1

    [CLOSED] Read Only NumberField

    I'm having trouble reading the current value of a NumberField set to readonly=true. I'm updating the number in the field with a button and direct event and then showing the results in an alert. When I click the Show button, I get the default value and not the value in the field. If the NumberField is set to readonly=false, it works fine. Please let me know if I'm missing something...code sample follows.

    Thank you.

     
    <head runat="server">
        <title></title>
        <script runat="server" >
            Protected Sub Button1_Click(ByVal sender As Object, ByVal e As AjaxEventArgs)
                ScriptManager1.AddScript("Ext.Msg.alert('Alert', '" & numNet.Number & "');")
            End Sub
            Protected Sub Button2_Click(ByVal sender As Object, ByVal e As AjaxEventArgs)
                numNet.Number = 5.12
            End Sub
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
             <ext:ScriptManager ID="ScriptManager1" runat="server" />                         
             <ext:NumberField ID="numNet" runat="server" FieldLabel="Net" Width="100" AllowDecimals="true" TrimTrailedZeros="False" ReadOnly="True" />
            <ext:Button ID="Button1" runat="server" Text="Show">
                <AjaxEvents>
                    <Click OnEvent="Button1_Click" />
                </AjaxEvents>
            </ext:Button>
       
            <ext:Button ID="Button2" runat="server" Text="Set Number">
                <AjaxEvents>
                    <Click OnEvent="Button2_Click" />
                </AjaxEvents>
            </ext:Button>
        </div>
        </form>
    </body>
    Last edited by Daniil; Nov 04, 2010 at 9:51 PM. Reason: [CLOSED]
  2. #2
    Don't use numNet.Number to set the value, use numNet.value = 5.12
  3. #3
    Hi iansriley,

    Yes, ljankowski is right, please use the NumberField's Value property.

    Example
    numNet.Value = 5.12
  4. #4
    Just getting a blank (empty string) now. Any other possibilities?

     
        <script runat="server" >
            Protected Sub Button1_Click(ByVal sender As Object, ByVal e As AjaxEventArgs)
                ScriptManager1.AddScript("Ext.Msg.alert('Alert', '" & numNet.Value & "');")
            End Sub
            Protected Sub Button2_Click(ByVal sender As Object, ByVal e As AjaxEventArgs)
                numNet.Value = 5.12
            End Sub
        </script>
  5. #5
    You could manually send a NumberField's value as extra parameter.

    Example
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As AjaxEventArgs)
        Ext.Msg.Alert("Alert", e.ExtraParams.Item("value")).Show()
    End Sub
    ...
    <ext:Button ID="Button1" runat="server" Text="Show">
        <AjaxEvents>
            <Click OnEvent="Button1_Click">
                <ExtraParams>
                    <ext:Parameter Name="value" Value="numNet.getValue()" Mode="Raw" />
                </ExtraParams>
            </Click>
        </AjaxEvents>
    </ext:Button>
  6. #6
    That appears to work well; thank you for the workaround. I will consider this issue solved but out of curiosity, was this a bug in 8.2 that will be fixed in 1.0?
  7. #7
    Yes, in Ext.Net it works very well with any combination of properties Value, Number, Text, ReadOnly.

    By the way we strongly recommend to migrate on Ext.Net 1.0.
    You would be pleasantly surprised by the flexibility and power of this toolkit's version.
  8. #8
    Hi,

    The following example demonstrates your sample using v1.0 code.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
        protected void Button1_Click(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Alert", this.NumberField1.Number).Show();
        }
    
        protected void Button2_Click(object sender, DirectEventArgs e)
        {
            this.NumberField1.Number = 5.12;
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:NumberField 
                ID="NumberField1" 
                runat="server" 
                FieldLabel="Net"
                ReadOnly="true"
                />
    
            <ext:Button 
                runat="server" 
                Text="Set Number" 
                OnDirectClick="Button2_Click" 
                />
                
            <ext:Button 
                runat="server" 
                Text="Show" 
                OnDirectClick="Button1_Click" 
                />
        </form>
    </body>
    </html>
    Hope this helps.
    Geoffrey McGill
    Founder & CEO

Similar Threads

  1. Replies: 2
    Last Post: Jul 11, 2012, 6:18 PM
  2. Ext.NET Jobs - Please Read First
    By geoffrey.mcgill in forum Jobs
    Replies: 0
    Last Post: May 24, 2011, 8:34 PM
  3. [CLOSED] Formpanel read-only
    By 78fede78 in forum 1.x Premium Help
    Replies: 10
    Last Post: Oct 08, 2010, 4:40 PM
  4. [CLOSED] [1.0] TriggerField read-only
    By danielg in forum 1.x Premium Help
    Replies: 3
    Last Post: Nov 04, 2009, 11:15 AM
  5. [CLOSED] Read GridPanelRows
    By GmServizi in forum 1.x Premium Help
    Replies: 2
    Last Post: Aug 03, 2009, 1:40 PM

Posting Permissions