disable HTML tags in DataGrid Cells ( VS.Net 2003 )
-
Hi, Am trying to create a custom DataGrid control the only pursues of this controls is to disable the HTML tags to be drawn in grid cells. Am using VS.Net 2003 / C# This is the controls class
using System; using System.Data; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.ComponentModel; using System.IO; namespace MyControl { /// /// Summary description for CustomDataGrid. /// [DefaultProperty("Text"), ToolboxData("<{0}:CustomDataGrid runat=server>")] public class CustomDataGrid: DataGrid { public CustomDataGrid() { base.CopyBaseAttributes( this ); } protected override void OnItemDataBound(DataGridItemEventArgs e) { foreach( TableCell tblCell in e.Item.Cells) { tblCell.Text = tblCell.Text.Replace(">", ">").Replace("<", "<"); } base.OnItemDataBound (e); } } }
This is the HTML representation on the control on my ASPX Page<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="AspTest.WebForm1" %> <%@ Register TagPrefix="cc1" Namespace="MyControl" Assembly=" MyControl" %> WebForm1
-
Hi, Am trying to create a custom DataGrid control the only pursues of this controls is to disable the HTML tags to be drawn in grid cells. Am using VS.Net 2003 / C# This is the controls class
using System; using System.Data; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.ComponentModel; using System.IO; namespace MyControl { /// /// Summary description for CustomDataGrid. /// [DefaultProperty("Text"), ToolboxData("<{0}:CustomDataGrid runat=server>")] public class CustomDataGrid: DataGrid { public CustomDataGrid() { base.CopyBaseAttributes( this ); } protected override void OnItemDataBound(DataGridItemEventArgs e) { foreach( TableCell tblCell in e.Item.Cells) { tblCell.Text = tblCell.Text.Replace(">", ">").Replace("<", "<"); } base.OnItemDataBound (e); } } }
This is the HTML representation on the control on my ASPX Page<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="AspTest.WebForm1" %> <%@ Register TagPrefix="cc1" Namespace="MyControl" Assembly=" MyControl" %> WebForm1
-
Your ASPX page code doesn't look right. Have you posted it correctly?
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="AspTest.WebForm1" %> <%@ Register TagPrefix="cc1" Namespace="MyControl" Assembly="MyControl" %> WebForm1