FormPanel.getForm().getValues() don't encode xml special characters

Page 2 of 3 FirstFirst 123 LastLast
  1. #11
    Hello!

    You can encode manually:

    <script>
    	var encodeValues = function(values) {
    		var result = {};
    		for (i in values) {
    			result[i] = Ext.util.Format.htmlEncode(values[i]);
    		}
    		return result;
    	};
    </script>
    <ext:Parameter Name="Values" Value="encodeValues(FormPanel1.getForm().getValues())" Mode="Raw" />
    Let us know about your progress
  2. #12
    Quote Originally Posted by Baidaly View Post
    Hello!

    You can encode manually:

    <script>
    	var encodeValues = function(values) {
    		var result = {};
    		for (i in values) {
    			result[i] = Ext.util.Format.htmlEncode(values[i]);
    		}
    		return result;
    	};
    </script>
    <ext:Parameter Name="Values" Value="encodeValues(FormPanel1.getForm().getValues())" Mode="Raw" />
    Let us know about your progress
    It's work fine. thank you! I had always thought getValues return a string with xml format.
    Anyway, why getValues return a json format, but I got xml format on server side?
  3. #13
    Quote Originally Posted by devil View Post
    It's work fine. thank you! I had always thought getValues return a string with xml format.
    Anyway, why getValues return a json format, but I got xml format on server side?
    We are curious about this too and investigating.
  4. #14
    After some investigation and asking Ext.NET guru Vladimir, I can say that Ext.NET v1 makes an XML from JSON itself.

    Honestly, it was a surprise for me. I always use such parameters with Encode="true" or Ext.encode(value) and, respectively, work with JSON on server. By the way, do you really need XML there?

    It is rather the old code which has been written before applying Newtonsoft JSON solution in Ext.NET.

    So, this (converting to XML) is not used in Ext.NET v2.

    Thank you for the question! I was able to know something new about Ext.NET:)

    Just to clarify: the getValues() always return a JSON. So, it is definitely not a bug within this method.

    Also we are not going to implement an option to encode InnerXml since @Baidaly provided you with a solution.

    So, there is nothing to consider as a bug. Do you agree?
  5. #15
    I agree with you, it's not a bug, I know it is old version code, I think you can keep it in Ext.Net1.x but remove it in Ext.Net2.x, because I test it before in Ext.Net2.1, it's same with Ext.Net1.6, just suggestion.

    Unfortunately in my project, I had saved XML data to database, so I think I must use XML until my project upgrade.

    Fortunately, Baidaly give me a solution.

    Honestly, I prefer to JSON than XML, so if I use Ext.Net in new project, I will use below code.
    <ext:Parameter Name="Values" Value="Ext.encode(#{FormPanel1}.getForm().getValues())" Mode="Raw" />
    and then parse JSON string on server.

    Thanks for everybody. Thanks for all support, I'm a chinese, my english is not good enough, glad to you can understand what I said.
  6. #16
    There should not be XML in Ext.NET v2. And I was unable to reproduce it.

    Here is my test case.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public void Save(object sender, DirectEventArgs e)
        {
            var values = e.ExtraParams["test"]; // "{\"test\":\"test\"}" here
        }
    </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>
        <ext:ResourceManager runat="server" />
    
        <ext:Button runat="server" Text="Save">
            <DirectEvents>
                <Click OnEvent="Save">
                    <ExtraParams>
                        <ext:Parameter Name="test" Value="{ test: 'test' }" Mode="Raw" />
                    </ExtraParams>
                </Click>
            </DirectEvents>
        </ext:Button>
    </body>
    </html>
    Quote Originally Posted by devil View Post
    <ext:Parameter Name="Values" Value="Ext.encode(#{FormPanel1}.getForm().getValues())" Mode="Raw" />
    Or this way:
    <ext:Parameter Name="Values" Value="#{FormPanel1}.getForm().getValues()" Mode="Raw" Encode=true" />
    which is the same.

    P.S. Thank you for the kind words. By the way, your English is fully understandable.
  7. #17
    Quote Originally Posted by Daniil View Post
    Or this way:
    <ext:Parameter Name="Values" Value="#{FormPanel1}.getForm().getValues()" Mode="Raw" Encode=true" />
    which is the same.
    Thanks, it's very useful.

    And I run you test case in my computer, very strange!!! it's XML. see screenshot.

    Click image for larger version. 

Name:	QQ截图20130123004731.png 
Views:	112 
Size:	52.9 KB 
ID:	5444

    I can send all solution to you include dll if you want.
  8. #18
    Please clarify what is the version of your Ext.NET dll?
  9. #19
    Quote Originally Posted by Daniil View Post
    Please clarify what is the version of your Ext.NET dll?
    I test both 1.6 and 2.1, the Ext.Net dll is download from github. I also check Newtonsoft.Json.dll,below is my local dll version info.

    Ext.Net.dll 1.6.0.213
    Ext.Net.Utilities.dll 1.3.0.39155
    Newtonsoft.Json.dll 4.0.8.14612
    ---------------------------------------
    Ext.Net.dll 2.1.0.3442
    Ext.Net.Utilities.dll 2.1.0.0
    Newtonsoft.Json.dll 4.5.10.15407
    Transformer.NET.dll 2.1.0.0
  10. #20
    Hi everybody,

    I suggest you download dll from github to test first, maybe your local code is different from github version
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 8
    Last Post: Mar 15, 2013, 2:24 AM
  2. Replies: 2
    Last Post: Aug 09, 2011, 10:49 PM
  3. Replies: 0
    Last Post: Jun 11, 2010, 2:04 AM
  4. [CLOSED] Turkish special characters problem
    By tansu in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: May 26, 2009, 12:01 PM

Tags for this Thread

Posting Permissions