PDA

View Full Version : [CLOSED] [#1389] [4.2.0] TextField - CodeBehind problem



mhajhammami
Oct 04, 2016, 12:33 PM
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?

fabricio.murta
Oct 05, 2016, 2:56 AM
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!

mhajhammami
Oct 05, 2016, 8:25 AM
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.

fabricio.murta
Oct 05, 2016, 4:49 PM
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).

fabricio.murta
Oct 05, 2016, 4:55 PM
We've just created issue #1389 (https://github.com/extnet/Ext.NET/issues/1389) on our bug tracker to report and fix this problem!

mhajhammami
Oct 05, 2016, 5:10 PM
Thank u Fabricio for reactivity.

Waiting for fix.

Best regards.

fabricio.murta
Oct 05, 2016, 8:33 PM
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.

mhajhammami
Oct 05, 2016, 9:00 PM
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.

mhajhammami
Oct 14, 2016, 4:22 PM
Hello Fabricio,

Any news about the issue?

fabricio.murta
Oct 15, 2016, 5:00 PM
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>

fabricio.murta
Nov 02, 2016, 4:10 AM
Hello again!

We have just fixed this issue in our latest developer's snapshot of Ext.NET Mobile!.. The fix will be publicly available in the next public Ext.NET Mobile release (4.2, no due date as of now), but it is already available for premium subscription users (http://ext.net/store/)!