[CLOSED] SelectBox: Problem with characters "<" and ">"

  1. #1

    [CLOSED] SelectBox: Problem with characters "<" and ">"

    Hi,

    I am having some issue with characters "<" and ">" in the SelectBox.
    If I use "<abc><def>", it will not be displayed in the List, but it will be displayed in the SelectBox properly.
    If I use "&lt;ghi&gt;", it will be correctly displayed in the List as "<ghi>" but it will be incorrectly displayed in the SelectBox as "&lt;ghi&gt;".

    Can you advice how I can show values that contain "<" and ">" for both the SelectBox and the List?

    Complete HTML:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="WebApplication.ExtNet.Trending.Test" ValidateRequest="false" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <html>
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
    
    <ext:ResourceManager ID="ResourceManager_Trending" runat="server" IDMode="Explicit" />
    <ext:SelectBox ID="SelectBox1" runat="server" ValueField="Code" DisplayField="Description" Width="120">
      <Store>
        <ext:Store ID="storeSelectBox1" runat="server">
          <Reader>
            <ext:ArrayReader>
              <Fields>
                <ext:RecordField Name="Code" />
                <ext:RecordField Name="Description" />
              </Fields>
            </ext:ArrayReader>
          </Reader>            
        </ext:Store>    
      </Store>
    </ext:SelectBox>
    
        </form>
    </body>
    </html>
    Complete Server-Side Codes:
    using System;
    using Ext.Net;
    
    namespace WebApplication.ExtNet.Trending
    {
        public partial class Test : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                object[] datasource = new object[3];
                datasource[0] = new object[] { 1, "Value 1" };
                datasource[1] = new object[] { 2, "<abc><def>" };
                datasource[2] = new object[] { 3, "&lt;ghi&gt;" };
                var store = this.SelectBox1.GetStore();
                store.DataSource = datasource;
                store.DataBind();
            }
        }
    }
    Last edited by Daniil; Nov 03, 2011 at 6:50 AM. Reason: [CLOSED]
  2. #2
    Please see
    http://forums.ext.net/showthread.php...ll=1#post16709

    I suggest to use Template and encode values in the template
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    Hi Vladimir,

    Thanks for the quick response.

    I managed to make it work. Thank you and please close this ticket.



    <ext:SelectBox ID="SelectBox1" runat="server" ValueField="Code" DisplayField="Description" Width="120">
      <Store>
        <ext:Store ID="storeSelectBox1" runat="server">
          <Reader>
            <ext:ArrayReader>
              <Fields>
                <ext:RecordField Name="Code"  />
                <ext:RecordField Name="Description"  />
              </Fields>
            </ext:ArrayReader>
          </Reader>         
        </ext:Store>    
      </Store>
      <Template ID="Template_SelectBox1" runat="server">
        <Html>
          <tpl for=".">
            <div class="x-combo-list-item">{Description:htmlEncode}</div>
          </tpl>
        </Html>
      </Template>
    </ext:SelectBox>
  4. #4
    You need to set up a respective ItemSelector or use the default one this way.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                object[] datasource = new object[3];
                datasource[0] = new object[] { 1, "Value 1" };
                datasource[1] = new object[] { 2, "<abc><def>" };
                datasource[2] = new object[] { 3, "&lt;ghi&gt;" };
                var store = this.SelectBox1.GetStore();
                store.DataSource = datasource;
                store.DataBind();
            }
        }
    </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:SelectBox 
                ID="SelectBox1"
                runat="server" 
                ValueField="Code" 
                DisplayField="Description"
                Width="120">
                <Store>
                    <ext:Store runat="server">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="Code" />
                                    <ext:RecordField Name="Description" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <Template runat="server">
                    <Html>
                        <tpl for=".">
                            <div class="x-combo-list-item">{Description:htmlEncode}</div>
                        </tpl>
                    </Html>
                </Template>
            </ext:SelectBox>
        </form>
    </body>
    </html>
  5. #5
    Thanks Daniil, it now works perfectly. Please close this ticket.

Similar Threads

  1. [CLOSED] How does "MaskCls" work for "AutoLoad" mask in panel control
    By leon_tang in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 19, 2012, 12:09 PM
  2. Replies: 1
    Last Post: Jun 26, 2012, 11:29 AM
  3. Replies: 5
    Last Post: May 02, 2012, 5:37 PM
  4. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  5. Replies: 2
    Last Post: Jun 26, 2011, 1:59 AM

Tags for this Thread

Posting Permissions