Border Attribute on Table Webcontrol

Discussion in 'ASP .Net' started by Unknown, Feb 1, 2004.

  1. Unknown

    Unknown Guest

    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
     
    Unknown, Feb 1, 2004
    #1
    1. Advertising

  2. Unknown

    Keith Guest

    Code sample would help. Otherwise this could be about 10
    different issues.

    >-----Original Message-----
    >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
    >
    >
    >.
    >
     
    Keith, Feb 1, 2004
    #2
    1. Advertising

  3. Unknown

    Unknown Guest

    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>
     
    Unknown, Feb 1, 2004
    #3
  4. Unknown

    Tom Kiefer Guest

    Have you tried, instead of

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


    simply

    tbl.Border = 1;

    http://msdn.microsoft.com/library/e...ebuihtmlcontrolshtmltableclassbordertopic.asp

    - Tom Kiefer
    thogek @ earthlink . net


    "Unknown" <> wrote in message
    news:...
    >
    > 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>
    >
    >
     
    Tom Kiefer, Feb 1, 2004
    #4
  5. Unknown

    Unknown Guest

    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



    "Tom Kiefer" <> wrote in message
    news:...
    > Have you tried, instead of
    >
    > > tbl.Attributes["border"] = "1";

    >
    > simply
    >
    > tbl.Border = 1;
    >
    >

    http://msdn.microsoft.com/library/e...ebuihtmlcontrolshtmltableclassbordertopic.asp
    >
    > - Tom Kiefer
    > thogek @ earthlink . net
    >
    >
    > "Unknown" <> wrote in message
    > news:...
    > >
    > > 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>
    > >
    > >

    >
    >
     
    Unknown, Feb 2, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QmlsbCBFbmRvdw==?=

    Duplicate BORDER attribute in WebControl.Table

    =?Utf-8?B?QmlsbCBFbmRvdw==?=, Jul 29, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    1,606
    =?Utf-8?B?QmlsbCBFbmRvdw==?=
    Jul 29, 2004
  2. tshad
    Replies:
    0
    Views:
    2,304
    tshad
    Jan 31, 2005
  3. phl
    Replies:
    1
    Views:
    4,418
    Martin Jay
    Jun 8, 2006
  4. =?Utf-8?B?cm9kY2hhcg==?=

    html table border attribute and css

    =?Utf-8?B?cm9kY2hhcg==?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    470
    =?Utf-8?B?cm9kY2hhcg==?=
    Oct 5, 2007
  5. rodchar

    table border attribute

    rodchar, Mar 20, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    424
    Sam Allen
    Mar 20, 2008
Loading...

Share This Page