[CLOSED] HTML encoding with grid - cannot send a value

  1. #1

    [CLOSED] HTML encoding with grid - cannot send a value

    Hi,



    I have a grid panel with a JSON store. One of the record fields type is
    string. If the following value is returned in that column by the store,
    then the load exception is raised on the client side (C# code):



    
    string value = "\""";




    Whether I do HtmlEncode or not before sending it to the client, it
    doesn't matter, because I always end up with " in the string.
    This when sent to the client gets converted to just " (double quotes) and this
    character included in the JSON data makes the whole JSON data invalid (that's because the string values in JSON are enclosed in double quotes).

    How can I send such a value to the grid?

    Regards,
    Tadeusz



  2. #2

    RE: [CLOSED] HTML encoding with grid - cannot send a value

    Hi,

    Can you create simple example? I can't get any exception
  3. #3

    RE: [CLOSED] HTML encoding with grid - cannot send a value

    Hi,

    I'm having problems replicating it although I believe I have created a similar configuration (the original one is embedded in more complex controls, so it's difficult to recreate the exact configuration). The only difference I can see is that in my application, the data is posted as multipart/form-data, but I don't suppose that makes a difference.

    I have traced it to the point where the JSON returned by the store's OnRefreshData handler is correct, i.e. it contains " string (I can see that e.g. in Fiddler), but inside Coolite's implementation of Ext.data.Connection.handleResponse, the response.responseText variable contains the same JSON text, but as if it has been html decoded (" is replaced by "). In the separate sample, in which I tried to replicate it, the response.responseText contains still the " string.


    It seems that somewhere before the Ext.data.Connection.handleResponse method, the text get html decoded. Do you have an idea where I could set a breakpoint in Coolite/ExtJS sources to see the response as soon as it is retrieved from the server and before it get a chance to be altered?

    Thanks,
    Tadeusz
  4. #4

    RE: [CLOSED] HTML encoding with grid - cannot send a value

    Hi,

    After dissecting my application, here is the sample that replicates it (you should receive an error message after you start this example):

    <%@ Page Language="C#" EnableEventValidation="false" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!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">
        <script runat="server">
            protected void Store1_RefreshData( object sender, StoreRefreshDataEventArgs e )
            {
    
                var source = new System.Collections.Generic.List<object>();
                source.Add( new
                {
                    Common = @"&amp;quot;"
                } );
                Store1.DataSource = source;
                Store1.DataBind();
            }
        </script>
    
    </head>
    <body>
        <form id="mainForm" runat="server">    
        <ext:ScriptManager ID="ScriptManager1" runat="server" />
        <ext:FileUploadField runat="server">
        </ext:FileUploadField>
        <ext:Store runat="server" ID="Store1" AutoLoad="true" OnRefreshData="Store1_RefreshData">
            <Proxy>
                <ext:DataSourceProxy />
            </Proxy>
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="Common" Type="String" />
                        
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <SortInfo Field="Common" Direction="ASC" />
        </ext:Store>
        <ext:Window runat="server" Collapsible="true" Height="500" Width="1000">
            <Body>
                <ext:FitLayout ID="FitLayout1" runat="server">
                    <ext:GridPanel ID="GridPanel1" runat="server" AutoExpandColumn="Common" Title="Plants" Frame="false" StoreID="Store1">
                        <ColumnModel ID="ColumnModel1" runat="server">
                            <Columns>
                                <ext:Column ColumnID="Common" Header="Common Name" DataIndex="Common" Width="220" Sortable="true" />
                                
                            </Columns>
                        </ColumnModel>
                        <LoadMask ShowMask="true" />
                    </ext:GridPanel>
                </ext:FitLayout>
            </Body>
        </ext:Window>
        
        </form>
    </body>
    </html>

    When you remove either <form> or FileUpload, the the application executes fine. I'm not sure though how these all are related to each other.


    Regards,
    Tadeusz

  5. #5

    RE: [CLOSED] HTML encoding with grid - cannot send a value

    Hi,

    Thanks for the example. The problem that if file upload field is presented then iframe submiting is using (form submiting to the hidden iframe) to allow upload file fields. Therefore response passed through that iframe also and yor html will be converted to the normal representation


    The single solution which I can suggest now is add the following to the Store
    <AjaxEventConfig Type="Load" />

    It will force using normal Ajax request but you will loose ability to upload all other fields to the server with store request (but in mostly cases it is even preferable way because normaly the store should retrieve data from server only without submitting anu information). You can always to pass additional parameters to the server using BaseParams of the Store
  6. #6

    RE: [CLOSED] HTML encoding with grid - cannot send a value

    Hi,


    Thanks for the solution - it works perfect for me, as I don't want to upload all other fields with the store request.

    Regards,
    Tadeusz
  7. #7

    RE: [CLOSED] HTML encoding with grid - cannot send a value

    Hi,

    There is one problem with this solution though. The store uses now GET request and since the query string length is limited much in its length, we cannot send longer parameter values. Is there any workaround for this?

    Regards,
    Tadeusz
  8. #8

    RE: [CLOSED] HTML encoding with grid - cannot send a value

    Hi,

    Try the following
    <AjaxEventConfig Type="Load" Method="POST" />
  9. #9

    RE: [CLOSED] HTML encoding with grid - cannot send a value

    Thanks, it resolved it.

Similar Threads

  1. [CLOSED] How to send row to second grid
    By egvt in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 18, 2012, 6:33 PM
  2. Cant send html string as parameter to AjaxMethod
    By masudcseku in forum 1.x Help
    Replies: 9
    Last Post: Jul 19, 2011, 10:38 PM
  3. Can I send a string with html tag to Ajaxmethod?
    By masudcseku in forum 1.x Help
    Replies: 1
    Last Post: Jul 19, 2011, 10:31 PM
  4. [CLOSED] [1.0] Issue with encoding Html o xml values with Ext.encode
    By edigital in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Nov 15, 2010, 9:34 AM
  5. irregularity of server side html encoding
    By [WP]joju in forum 1.x Help
    Replies: 2
    Last Post: Dec 22, 2009, 10:54 AM

Posting Permissions