[CLOSED] [#1389] [4.2.0] TextField - CodeBehind problem

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] [#1389] [4.2.0] TextField - CodeBehind problem

    Hi,

    I just start using Ext.Net Mobile Web Forms. As old Ext.Net WebForms developer, i tried to apply the same approach.

    Here an example using TextField and two buttons:

    Markup:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Mobile.WebForm1" %>
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET Mobile Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <ext:Viewport ID="Viewport1" runat="server" Layout="VBoxLayout" Padding="10">
            <Items>
                <ext:FormPanel
                    ID="FormPanel1"
                    runat="server" >
                    <Items>
                        <ext:TitleBar ID="TitleBar1" runat="server" Docked="Top">
                            <Items>
                                <ext:Button ID="Button1" runat="server" Text="Get" OnClientTap="INTG.GetFormValues();" />
                                <ext:Button ID="Button2" runat="server" Text="Set" OnClientTap="INTG.SetFormValues();" />
                            </Items>
                        </ext:TitleBar>
                        <ext:FieldSet
                            ID="FieldSet1"
                            runat="server"
                            <Items>
                                <ext:TextField ID="TextField1" runat="server" Label="Title" Text="test" />
                            </Items>
                        </ext:FieldSet>
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Viewport>
    </body>
    </html>
    CodeBehind:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Ext.Net.Mobile;
    
    namespace Mobile
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            [DirectMethod(ShowMask = true)]
            public void SetFormValues()
            {
                TextField1.Text = "TESSSSSST";
            }
    
            [DirectMethod(ShowMask = true)]
            public void GetFormValues()
            {
                X.Msg.Alert("", TextField1.Text).Show();
            }
        }
    }
    The problem is that im not able to change the TextField text from codeBehind.

    Any idea?
    Last edited by fabricio.murta; Nov 02, 2016 at 4:10 AM.
  2. #2
    Hello @mhajhammami! Welcome to Ext.NET forums!

    After the page has been loaded, changing a controller's setting only has effect if you re-render the control. To change the value of an already rendered control, use its setter method, i.e. SetText("newText").

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello Fabricio and thank u for ur response.

    Sadly i cant find a SetText method attached to the TextField class.

    As an ASP.Net Server Control, TextField must have the possibility to manage its values throw codebehind, using viewstate or other techniques.

    Hope to find the way to do it, cause as mentionned, the EXT.Net mobile API concerns WebForms (so server controls).

    Regards.
  4. #4
    Hello @mhajhammami!

    Yes, sorry, the correct would be SetValue(object) but as per its signature it is not ideal. The Text property does not reflect an actual ExtJS field, so it is not straightforward placement.

    We will be reviewing this (as this probably is the case of Ext.NET -- not mobile -- text field as well).
    Fabrício Murta
    Developer & Support Expert
  5. #5
    We've just created issue #1389 on our bug tracker to report and fix this problem!
    Fabrício Murta
    Developer & Support Expert
  6. #6
    Thank u Fabricio for reactivity.

    Waiting for fix.

    Best regards.
  7. #7
    Just to ensure you got a short term solution: could you update the field with the SetValue() call? Probably it may require casting to object, or some other approach, so if you are still unable to update the value from code behind with this alternative, let us know.

    Another alternative to this would be TextField1.Call("setValue", "TESSST");, from code behind.
    Fabrício Murta
    Developer & Support Expert
  8. #8
    I already tried that approach by calling setValue jscript method from codebehind.

    I also tried to call the Update method after setting text value:

    TextField1.Text = "TESSSSST";
    TextField1.Update();
    With both solutions the TextField change its render value on the UI, but the server value still the original one (tested by showing from X.Alert.Show()).

    This problem is also the same with other controls (checkbox,...).

    I think the problem came from ResourceManager who dont manage well the state.

    Hope this help.

    Best regards.
  9. #9
    Hello Fabricio,

    Any news about the issue?
  10. #10
    Hello!

    Probably you didn't do something right there... Look at this example, it works:

    <%@ Page Language="C#" %>
    <!DOCTYPE html>
    <script runat="server">
        [DirectMethod(ShowMask = true)]
        public void SetFormValues()
        {
            TextField1.Call("setValue", "TESSSSST!");
        }
    
        [DirectMethod(ShowMask = true)]
        public void GetFormValues()
        {
            X.Msg.Alert("", TextField1.Text).Show();
        }
    </script>
    <html>
    <head runat="server">
        <title>Ext.NET Mobile Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <ext:Viewport ID="Viewport1" runat="server" Layout="VBoxLayout" Padding="10">
            <Items>
                <ext:FormPanel
                    ID="FormPanel1"
                    runat="server" >
                    <Items>
                        <ext:TitleBar ID="TitleBar1" runat="server" Docked="Top">
                            <Items>
                                <ext:Button ID="Button1" runat="server" Text="Get" OnClientTap="App.direct.GetFormValues();" />
                                <ext:Button ID="Button2" runat="server" Text="Set" OnClientTap="App.direct.SetFormValues();" />
                            </Items>
                        </ext:TitleBar>
                        <ext:FieldSet
                            ID="FieldSet1"
                            runat="server">
                            <Items>
                                <ext:TextField ID="TextField1" runat="server" Label="Title" Text="test" />
                            </Items>
                        </ext:FieldSet>
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Viewport>
    </body>
    </html>
    Fabrício Murta
    Developer & Support Expert
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] TextField in codebehind
    By vgvallee in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 10, 2013, 8:14 PM
  2. Replies: 0
    Last Post: Aug 01, 2012, 1:20 AM
  3. Problem getting Gridfilter settings in codebehind
    By plykkegaard in forum 1.x Help
    Replies: 0
    Last Post: Nov 22, 2009, 6:22 PM
  4. Replies: 0
    Last Post: Nov 18, 2009, 1:50 PM
  5. Replies: 2
    Last Post: Jul 08, 2009, 12:37 PM

Posting Permissions