G
Guest
I've noticed that the WebControl.Table class always outputs the attribute "border="0"", and I cannot stop it from doing so, no matter what I try. I end up with generated HTML that looks like:
<table border="1" border="0">
For example, create a new server control that inherits from System.Web.UI.Control, and call it CustomTable. Add an event handler for the Load event:
Protected Sub CustomTable_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim t As Table
Dim tr As TableRow
Dim td As TableCell
t = New Table
t.Attributes.Add("border", "1")
tr = New TableRow
td = New TableCell
td.Text = "Hello"
tr.Cells.Add(td)
t.Rows.Add(tr)
Me.Controls.Add(t)
End Sub
Create an aspx page, and add your Register stuff at the top:
<%@ Register TagPrefix="CustomTable" Namespace="CustomTable" Assembly = "CustomTable" %>
Then, add the element in the <body>:
<CustomTable:CustomTable runat="server" id="CustomTable1"/>
When you view the web page, you'll see <table border="1" border="0">...
I tried finding somewhere on the MS site where I could submit this as a bug, so I'm hoping someone at MS reads this. If anyone does, is there a workaround?
Thanks,
Bill
<table border="1" border="0">
For example, create a new server control that inherits from System.Web.UI.Control, and call it CustomTable. Add an event handler for the Load event:
Protected Sub CustomTable_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim t As Table
Dim tr As TableRow
Dim td As TableCell
t = New Table
t.Attributes.Add("border", "1")
tr = New TableRow
td = New TableCell
td.Text = "Hello"
tr.Cells.Add(td)
t.Rows.Add(tr)
Me.Controls.Add(t)
End Sub
Create an aspx page, and add your Register stuff at the top:
<%@ Register TagPrefix="CustomTable" Namespace="CustomTable" Assembly = "CustomTable" %>
Then, add the element in the <body>:
<CustomTable:CustomTable runat="server" id="CustomTable1"/>
When you view the web page, you'll see <table border="1" border="0">...
I tried finding somewhere on the MS site where I could submit this as a bug, so I'm hoping someone at MS reads this. If anyone does, is there a workaround?
Thanks,
Bill