all groups > asp.net > january 2004 >
You're in the

asp.net

group:

Border Attribute on Table Webcontrol


Border Attribute on Table Webcontrol Unknown
1/31/2004 11:35:15 PM
asp.net: When I create a Table webcontrol programmatically (no static table tag in
the aspx file), it renders in the HTML with a border attribute set to "0".

If I add my own border attribute--MyTable.Attributes.Add("border",
"1")--with a value of "1", the border attribute shows up twice in the HTML
tag in the browser.

How can I suppress the default border attribute of "0" for the Table
webcontrol?

Thanks
Phil

Border Attribute on Table Webcontrol Keith
2/1/2004 12:05:55 AM
Code sample would help. Otherwise this could be about 10
different issues.

[quoted text, click to view]
Re: Border Attribute on Table Webcontrol Unknown
2/1/2004 9:18:57 AM

Pretty basic stuff here. Below you will find the code for the aspx file,
the c# code behind file, and the html markup taken from "view source" in the
browser window. Please note that the border attribute is repeated twice in
HTML file for the table.

The operating environment is:
-- VS.Net: 7.0
-- .Net Framework: 1.0
-- IE: 6.0

Thanks,
Phil

----------------
ASPX file:
----------------

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
Inherits="TableBorder.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

</form>

</body>
</HTML>

----------------
Code behind:
----------------

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace TableBorder
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
Table tbl = new Table();

tbl.Attributes["border"] = "1";

Control FormControl = FindControl("Form1");

FormControl.Controls.Add(tbl);
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}

----------------
HTML file
----------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">

<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtMTI3OTMzNDM4NDs7Po6uD/OBrot+Jddth/EAV3CvXJRf" />


<table border="1" border="0">

</table></form>

</body>
</HTML>

Re: Border Attribute on Table Webcontrol Tom Kiefer
2/1/2004 3:26:47 PM
Have you tried, instead of

[quoted text, click to view]

simply

tbl.Border = 1;

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuihtmlcontrolshtmltableclassbordertopic.asp

- Tom Kiefer
thogek @ earthlink . net


[quoted text, click to view]

Re: Border Attribute on Table Webcontrol Unknown
2/1/2004 10:52:04 PM
Using "tbl.Border = 1" seems to create an inline CSS style; We want to use
only the border attribute of the table element in this particular case for a
number of unrelated reasons.

Phil



[quoted text, click to view]

AddThis Social Bookmark Button