Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > asp:Table and border-collapse

Reply
Thread Tools

asp:Table and border-collapse

 
 
Michael Tissington
Guest
Posts: n/a
 
      08-01-2003
I'm using the asp:Table control and it insists on adding the style
"border-collapse:collapse;"

Any idea how I can make it use the default of separate?

Thanks.

--
Michael Tissington
Oaklodge Technologies
http://www.oaklodge.com/technology



 
Reply With Quote
 
 
 
 
Victor Garcia Aprea [MVP]
Guest
Posts: n/a
 
      08-04-2003
Hi Michael,

Try:
[C#]
YourTable.Style["border-collapse"] = "separate";

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.

"Michael Tissington" <> wrote in message
news:%...
> I'm using the asp:Table control and it insists on adding the style
> "border-collapse:collapse;"
>
> Any idea how I can make it use the default of separate?
>
> Thanks.
>
> --
> Michael Tissington
> Oaklodge Technologies
> http://www.oaklodge.com/technology
>
>
>



 
Reply With Quote
 
 
 
 
Michael Tissington
Guest
Posts: n/a
 
      08-04-2003
I tried this and it does not help (in the Page_Load) - why is it defaulting
to this?

--
Michael Tissington
Oaklodge Technologies
http://www.oaklodge.com/technology

"Victor Garcia Aprea [MVP]" <> wrote in message
news:...
> Hi Michael,
>
> Try:
> [C#]
> YourTable.Style["border-collapse"] = "separate";
>
> --
> Victor Garcia Aprea
> Microsoft MVP | ASP.NET
> Looking for insights on ASP.NET? Read my blog:
> http://obies.com/vga/blog.aspx
> To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
> and not by private mail.
>
> "Michael Tissington" <> wrote in message
> news:%...
> > I'm using the asp:Table control and it insists on adding the style
> > "border-collapse:collapse;"
> >
> > Any idea how I can make it use the default of separate?
> >
> > Thanks.
> >
> > --
> > Michael Tissington
> > Oaklodge Technologies
> > http://www.oaklodge.com/technology
> >
> >
> >

>
>



 
Reply With Quote
 
Victor Garcia Aprea [MVP]
Guest
Posts: n/a
 
      08-05-2003
I tried my code and its working for me. Maybe there is something else wrong
in your code?

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.


"Michael Tissington" <> wrote in message
news:...
> I tried this and it does not help (in the Page_Load) - why is it

defaulting
> to this?
>
> --
> Michael Tissington
> Oaklodge Technologies
> http://www.oaklodge.com/technology
>
> "Victor Garcia Aprea [MVP]" <> wrote in message
> news:...
> > Hi Michael,
> >
> > Try:
> > [C#]
> > YourTable.Style["border-collapse"] = "separate";
> >
> > --
> > Victor Garcia Aprea
> > Microsoft MVP | ASP.NET
> > Looking for insights on ASP.NET? Read my blog:
> > http://obies.com/vga/blog.aspx
> > To contact me remove 'NOSPAM'. Please post all questions to the

newsgroup
> > and not by private mail.
> >
> > "Michael Tissington" <> wrote in message
> > news:%...
> > > I'm using the asp:Table control and it insists on adding the style
> > > "border-collapse:collapse;"
> > >
> > > Any idea how I can make it use the default of separate?
> > >
> > > Thanks.
> > >
> > > --
> > > Michael Tissington
> > > Oaklodge Technologies
> > > http://www.oaklodge.com/technology
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Yan-Hong Huang[MSFT]
Guest
Posts: n/a
 
      08-05-2003
Hello Michael,

Victor is right and I have also tested it on my side.

By the way, in order to stop the System.Web.UI.WebControls.Table() class from rendering the "border-collapse:collapse"
style property in the <TABLE> tag, we could set CellSpacing to something other than 0.

There isn't a way to get rid of border-collapse if you set CellSpacing to 0.

Perhaps there should have been a way to override this behavior. Tables with cellspacing=0 with the borders collapsed don't
look like they have really 0 cellspacing (visually), because each cell has a border. Therefore to make it appear that there is
absolutely no space between cells, we add this style attribute.

Here's what you should do:
1. Write a MyTable control deriving from Table
2. In there override CreateControlStyle to plug in a derived style
protected override Style CreateControlStyle() {
return new MyTableStyle(ViewState);
}
3. Write the MyTableStyle class deriving from TableStyle like so:

public class MyTableStyle : TableStyle {
private bool _rendering;

public override int CellSpacing {
get {
if (_rendering) {
return -1;
}
return base.CellSpacing;
}
set {
base.CellSpacing = value;
}
}

public override void AddAttributesToRender(HtmlTextWriter writer, WebControl owner) {
try {

_rendering = true;
base.AddAttributesToRender(writer, owner);
}
finally {
_rendering = false;
}
int n = CellSpacing;
if (n >= 0) {
writer.AddAttribute(HtmlTextWriterAttribute.CellSp acing, n.ToString(CultureInfo.InvariantCulture));
}
}
}

That should do the trick... of course this is email code based on memory of the code, so it might need small modifications to
fully work.

Thanks very much for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Michael Tissington" <>
!References: <#> <>
!Subject: Re: asp:Table and border-collapse
!Date: Mon, 4 Aug 2003 07:03:41 -0700
!Lines: 44
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <>
!Newsgroups:
microsoft.public.dotnet.framework.aspnet.buildingc ontrols,microsoft.public.dotnet.framework.aspnet.w ebcontrols
!NNTP-Posting-Host: antelope.oaklodge.com 63.67.71.5
!Path: cpmsftngxa06.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08.phx.gbl!
TK2MSFTNGP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontro ls:13640
microsoft.public.dotnet.framework.aspnet.buildingc ontrols:6909
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
!
!I tried this and it does not help (in the Page_Load) - why is it defaulting
!to this?
!
!--
!Michael Tissington
!Oaklodge Technologies
!http://www.oaklodge.com/technology
!
!"Victor Garcia Aprea [MVP]" <> wrote in message
!news:...
!> Hi Michael,
!>
!> Try:
!> [C#]
!> YourTable.Style["border-collapse"] = "separate";
!>
!> --
!> Victor Garcia Aprea
!> Microsoft MVP | ASP.NET
!> Looking for insights on ASP.NET? Read my blog:
!> http://obies.com/vga/blog.aspx
!> To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
!> and not by private mail.
!>
!> "Michael Tissington" <> wrote in message
!> news:%...
!> > I'm using the asp:Table control and it insists on adding the style
!> > "border-collapse:collapse;"
!> >
!> > Any idea how I can make it use the default of separate?
!> >
!> > Thanks.
!> >
!> > --
!> > Michael Tissington
!> > Oaklodge Technologies
!> > http://www.oaklodge.com/technology
!> >
!> >
!> >
!>
!>
!
!
!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if and and vs if and,and titi VHDL 4 03-11-2007 05:23 AM



Advertisments