PDA

View Full Version : [CLOSED] Problem with special characters in selectbox



xeo4.it
Dec 05, 2013, 4:29 PM
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>

Baidaly
Dec 05, 2013, 7:08 PM
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>

xeo4.it
Dec 10, 2013, 7:50 AM
Hi Baidaly (http://forums.ext.net/member.php?3790-Baidaly),
it works fine.
Thank you very much