[CLOSED] Problem with special characters in selectbox

  1. #1

    [CLOSED] Problem with special characters in selectbox

    Hi,
    I need to insert in a selctbox a description with special characters: <NULL>.
    If I put directly <NULL> the selectbox does not show it, if I put &lt;NULL&gt; the list of the selecbox is correct but not the value in field.
    See my example.
    Thank you

    Jimmy

    <%@ Page Language="C#" %>
    
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
          Store store = this.SelectBox1.GetStore();
            
          store.DataSource = new object[]
          {
            new object[] { "99", "&lt;NULL&gt;", "NO DATA" },
            new object[] { "AL", "Alabama", "The Heart of Dixie" },
            new object[] { "AK", "Alaska", "The Land of the Midnight Sun" },
            new object[] { "AZ", "Arizona", "The Grand Canyon State" },
          };
            
          store.DataBind();
    
    
          this.SelectBox1.Select("99");
          this.SelectBox1.SelectedItem.Value = "99";
          
        }
    </script>
    
    
    <!DOCTYPE html>
    
    
    <html>
    <head id="Head1" runat="server">
        <title>SelectBox - Ext.NET Examples</title>
      </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
                    
            <ext:SelectBox
                ID="SelectBox1"
                runat="server" 
                DisplayField="state"
                ValueField="abbr"
                EmptyText="Select a state...">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model ID="Model1" runat="server">
                                <Fields>
                                    <ext:ModelField Name="abbr" />
                                    <ext:ModelField Name="state" />
                                    <ext:ModelField Name="nick" />
                                </Fields>
                            </ext:Model>
                        </Model>            
                    </ext:Store>    
                </Store>    
            </ext:SelectBox>
        </form>
    </body>
    </html>
    Last edited by Daniil; Dec 10, 2013 at 11:56 AM. Reason: [CLOSED]
  2. #2
    Hello!

    In this case, you need to declare special template with htmlEncode like in the example below:

    <%@ Page Language="C#" %>
     
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
          Store store = this.SelectBox1.GetStore();
             
          store.DataSource = new object[]
          {
            new object[] { "99", "<NULL>", "NO DATA" },
            new object[] { "AL", "Alabama", "The Heart of Dixie" },
            new object[] { "AK", "Alaska", "The Land of the Midnight Sun" },
            new object[] { "AZ", "Arizona", "The Grand Canyon State" },
          };
             
          store.DataBind();
     
     
          this.SelectBox1.Select("99");
          this.SelectBox1.SelectedItem.Value = "99";
           
        }
    </script>
     
     
    <!DOCTYPE html>
     
     
    <html>
    <head id="Head1" runat="server">
        <title>SelectBox - Ext.NET Examples</title>
      </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
                     
            <ext:SelectBox
                ID="SelectBox1"
                runat="server"
                DisplayField="state"
                ValueField="abbr"
                EmptyText="Select a state...">
                <Store>
                    <ext:Store ID="Store1" runat="server">
                        <Model>
                            <ext:Model ID="Model1" runat="server">
                                <Fields>
                                    <ext:ModelField Name="abbr" />
                                    <ext:ModelField Name="state">
                                    </ext:ModelField>
                                    <ext:ModelField Name="nick" />
                                </Fields>
                            </ext:Model>
                        </Model>            
                    </ext:Store>    
                </Store>    
                <Tpl runat="server">
                    <Html>
                        <tpl for=".">
                            <div class="x-boundlist-item">{state:htmlEncode}</div>
                        </tpl></Html>
                </Tpl>
            </ext:SelectBox>
        </form>
    </body>
    </html>
  3. #3
    Hi Baidaly,
    it works fine.
    Thank you very much

Similar Threads

  1. Replies: 28
    Last Post: Jan 23, 2013, 2:22 PM
  2. [CLOSED] ColumnName with Special Characters in GridPanel
    By UnifyEducation in forum 2.x Premium Help
    Replies: 1
    Last Post: Jun 07, 2012, 8:12 PM
  3. Replies: 0
    Last Post: Jun 11, 2010, 3:04 AM
  4. [CLOSED] Turkish special characters problem
    By tansu in forum 1.x Premium Help
    Replies: 6
    Last Post: May 26, 2009, 1:01 PM

Posting Permissions