May 18, 2011, 12:41 AM
[CLOSED] html tag in text content breaks app
Hi everyone,
I'm trying to build an asset managment tool.
Left: category navigation by tree.
Top: asset navigation by grid.
Bottom: editor pane, inside a FormPanel.
The problem I'm having is that when I load an asset whose name and description contain html tags in the text, my app fails. Otherwise it functions as designed.
Specifically, after clicking the Bollay row in my grid, the directmethod fires and the TextFields in the form are loaded. However after that client clicks are not handled - clicking on a category does nothing, clicking on an asset does nothing. Not sure why, any help would be appreciated.
Problem data:
I'm trying to build an asset managment tool.
Left: category navigation by tree.
Top: asset navigation by grid.
Bottom: editor pane, inside a FormPanel.
The problem I'm having is that when I load an asset whose name and description contain html tags in the text, my app fails. Otherwise it functions as designed.
Specifically, after clicking the Bollay row in my grid, the directmethod fires and the TextFields in the form are loaded. However after that client clicks are not handled - clicking on a category does nothing, clicking on an asset does nothing. Not sure why, any help would be appreciated.
Problem data:
AssetCategory { "AssetCategoryID" : "3", "Name" : "Client Alerts", "Description" : "Client Alert Assets" }
Asset { "AssetID" : "154", "Name" : "<i>Bollay v. California Office of Administrative Law</i>: State Agency Policies Asset Main", "Description" : "<i>Bollay v. California Office of Administrative Law</i>: State Agency Policies Asset Description", "AssetCategoryID" : "3", "ExpirationDate" : "2011-07-02 10:46:36.910" }
Assets.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Assets.aspx.cs" Inherits="LW4.WWW.Admin.Web.Assets" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" 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">
<title></title>
<style type="text/css">
#PanelFrame > .x-panel-header
{
background-image: url(Images/panelHeaderBackgroung-DarkBlue.png);
color: White;
}
</style>
</head>
<body>
<ext:ResourceManager runat="server" ID="ResourceManager1" />
<form id="form1" runat="server">
<ext:Viewport runat="server" ID="ViewportMain" StyleSpec="background-color: #DFE8F6;" Layout="Fit">
<Items>
<ext:Panel runat="server" ID="PanelFrame" Layout="Border" Title="Asset Library">
<Items>
<ext:Panel runat="server" ID="PanelNavigation" Title="Navigation" Region="West" Width="200px" Margins="4 0 4 4" Split="true" Collapsible="true">
<Items>
<ext:TreePanel runat="server" ID="TreeNavigation" Border="false" />
</Items>
</ext:Panel>
<ext:Panel runat="server" ID="PanelContent" Region="Center" Margins="4 4 4 0" Split="true" Layout="Border" Border="false">
<Items>
<ext:Panel runat="server" ID="PanelList" Title="Assets" Region="North" Split="true" Layout="Fit" Height="240">
<Items>
<ext:GridPanel runat="server" ID="GridAssets" StripeRows="true" TrackMouseOver="true" AutoExpandColumn="Description" Border="false">
<Store>
<ext:Store runat="server" ID="AssetStore">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="AssetID" />
<ext:RecordField Name="Name" />
<ext:RecordField Name="Description" />
<ext:RecordField Name="ExpirationDate" Type="Date" DateFormat="c" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ColumnID="AssetID" Header="Asset ID" DataIndex="AssetID" Hidden="true" />
<ext:Column ColumnID="Name" Header="Name" DataIndex="Name" Width="500" />
<ext:Column ColumnID="Description" Header="Description" DataIndex="Description" />
<ext:Column ColumnID="Expiration" Header="Expiration" DataIndex="ExpirationDate">
<Renderer Fn="Ext.util.Format.dateRenderer('m/d/Y')" />
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" SingleSelect="true" />
</SelectionModel>
<Listeners>
<RowClick Handler="Ext.net.DirectMethods.RowClick(item.getSelectionModel().getSelected().data.AssetID);" />
</Listeners>
</ext:GridPanel>
</Items>
</ext:Panel>
<ext:Panel runat="server" ID="PanelEditor" Region="Center" Split="true" Layout="Fit">
<Items>
<ext:FormPanel runat="server" ID="FormEditor" Padding="8" ButtonAlign="Right" Border="false" MonitorValid="true" Visible="false">
<Items>
<ext:TextField runat="server" ID="txtName" FieldLabel="Name" Anchor="95%" MaxLength="100" />
<ext:TextField runat="server" ID="txtDesc" FieldLabel="Description" Anchor="95%" MaxLength="500" />
</Items>
<Buttons>
<ext:Button runat="server" ID="btnSave" Text="Save">
<Listeners>
<Click Handler="Ext.net.DirectMethods.SubmitForm();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:FormPanel>
</Items>
</ext:Panel>
</Items>
</ext:Panel>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>
</html>
Assets.aspx.cs:
using System;
using Ext.Net;
using LW2.Utilities;
namespace LW4.WWW.Admin.Web
{
public partial class Assets : System.Web.UI.Page
{
#region Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
LoadTree();
}
}
#endregion
#region LoadTree
private void LoadTree()
{
TreeNode root = new TreeNode("Categories");
root.Expanded = true;
TreeNavigation.Root.Add(root);
AssetCategoryCollection allAssetCategories = DBAccessor.AssetCategories.GetAllAssetCategories();
foreach (AssetCategory category in allAssetCategories)
{
TreeNode categoryNode = new TreeNode(category.Name, Icon.Images);
categoryNode.NodeID = category.AssetCategoryID.Value.ToString();
categoryNode.Listeners.Click.Handler = "Ext.net.DirectMethods.NodeClick(node.id);";
root.Nodes.Add(categoryNode);
}
}
#endregion
#region NodeClick
[DirectMethod]
public void NodeClick(string id)
{
try
{
int categoryID = int.Parse(id);
AssetCollection assets = DBAccessor.Assets.GetAssetsByCategory(categoryID);
assets.Sort(Asset.SortByName);
AssetStore.DataSource = assets;
AssetStore.DataBind();
}
catch (Exception ex)
{
InstanceLog.WriteLog(ex);
}
finally
{
PanelList.UpdateContent();
// Clear editor form
FormEditor.Visible = false;
PanelEditor.UpdateContent();
}
}
#endregion
#region RowClick
[DirectMethod]
public void RowClick(int AssetID)
{
Asset asset = DBAccessor.Assets.GetAsset(AssetID);
// TODO: Hydrate Form
txtName.Text = asset.Name;
txtDesc.Text = asset.Description;
FormEditor.Visible = true;
PanelEditor.UpdateContent();
}
#endregion
#region SubmitForm
[DirectMethod]
public void SubmitForm()
{
}
#endregion
}
}
Last edited by Daniil; May 18, 2011 at 7:25 PM.
Reason: [CLOSED]