![]() |
[asp.net/CSS] Override generated tables' style attributes?
If you slap a DataGrid on an asp.net page and leave the settings as default, it generates the table code with along with the following attributes:
cellspacing=0 border=1 rules="all" style="border-collapse:collapse;" ...and that sucks because hard coded HTML overrides any CSS you may have for that particular element. Any style I apply to it regarding border and border-spacing is just flat out ignored. My questions are: 1. Is there a way to prevent asp.net from tossing whatever garbage it wants into the table tags? I just want a pure clean tag with the corresponding id/class: <table id="myDataGrid" class="MainReport"> If not... 2. Is there a way to make sure that CSS overrides all? |
from my experience, asp.net has a lot of oddities when it comes to the rendered output... sometimes the output is far from w3c compliant, even with made up attributes or improperly named controls... the only way I can think to fix this is to create a new datagrid class which inherits from the datagrid and overrides the render method. i have no idea how to do this though, and i imagine it would be kind of complex.
|
What f00sion said, depending on the functionality you need you can also use a DataList or DataRepeater web control instead of a DataGrid. The DataRepeater control is a templeted control, which means you can specify the header, row, and footer HTML yourself.
|
Thanks, I'll try either creating a custom data grid or a new repeater.
Man, I've just aboud had it with this designer. It's just utter crap. I have all this perfectly formatted HTMLand the second I switch from design mode to HTML mode, the designer takes it upon itself to reformat and make everything as unreadble as humanly possible. It removes all the tabs/returns i have in place. I neatly indent everything so it makes it easier for me to update later and this designer just totally ruins that. I've even disabled the auto-formatting in the options when saving/switching view mode. Is there anyway to TRULY prevent it from doing this? I mean, if I delselect "auto-format when...", that means I don't want it.. so why is it still doing it? I really wish they'd test their stuff more before sending it off. It's so irritating working with such a buggy designer.. and there's nothing I can do about it. |
Tools->Options->Text Editor->HTML/XML->Format
Uncheck both 'Apply Automatic Formatting' options. (edit: Oops. I see this is what you already referred to. Well, then, the designer shouldn't actually do anything. Unless, god forbid, you use it to add a control or move stuff around. In that case, I don't think there's anything you can do. I get around this by not using the designer.) Also, under Tools->Options->HTML Designer->General, you can choose to default to the HTML, not Designer, view. |
Look here http://blogs.msdn.com/mikhailarkhipo...16/132886.aspx
for an explanation of the HTML mangling. FYIW, this is fixed in the next version (Whidbey) due out sometime in 2005 last I heard. This is fixed in the beta version I've got so I have faith that they won't do anything between now and release to screw it up. ::rolleyes: :D |
Quote:
It's funny, because I have this series of list items (the ul/li tags), and with each item, I put it between the <li> and </li> tags... but when formatting takes over, it REMOVES the closing li tag and then later proceeds to complain that a tag is missing :rolleyes: |
All times are GMT -8. The time now is 02:33 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project