trying to use <div> to hide a bunch of table rows

  • Thread starter Thread starter David
  • Start date Start date
D

David

I attempted the following

<div id="div" runat="server">
<tr><td></td></tr>
<tr><td></td></tr>
</div>

This is to hide a group of rows depending on some business rules in my code
behind.

It works. BUT.

When I go back to the aspx page, VS.NET has f*d it up by inserting the
</div> tag.

<div id="div" runat="server"></div>
<tr><td></td></tr>
<tr><td></td></tr>
<div></div>

Note to Microsoft. DO NOT EVER DO ME A FAVOR. NEVER ASKED FOR IT, SO
PLEEEEEESE.

Sorry... just had to get it off the chest. Obvously the editor does not
like what it sees and it "corrects" what it does not like. What do you
advise? I have a table with a bunch of rows that encapsulate fields. Under
certain business rules, I would like to hide a group of rows. I suppose I
could do this row by row, but that is a lot of work...
 
Hi David,

I know the visual studio.net does the reformatting of the html tags.. but
there is a good news for you that will no more be there in the Next version
Visual Studio 2005 based on the users feedback this is taken care in
Whidbey.

Right now my suggestion would be to use place holder controls if you are
facing too much problems with the html formatting using DIC or in Visual
Studion you take a look at the settings for

Options->Text Editor->Html-Xml->HTML Specific and see the autor insert
section.

Regards
Ashish M Bhonkiya
 
Actually, it is de-f*ing your improper HTML.

If you think the editor doesn't like it, you'll just love what some browsers
will do with it.

Bob Lehmann
 
I have been using ASP Panels for this type of thing, because of the issue
you are running into. Replace your divs with panels, and you can set the
visible property true or false.
 
Hi

This is not valid html so don't blame MS ;)

Try giving the <tr> you want to hide/display the same name

<tr name="myStuff"><td></td></tr>
<tr name="myStuff"><td></td></tr>

then to show..

function toggle(){
var e = document.getElementsByName("myStuff");
if(e != null)
{
// Get current status
var sDisplay = ( e.style.display == "none" ) ? "block" : "none";
for(i=0;i<e.length;i++)
{
e.style.display = sDisplay;
}
}
}

More info:
http://msdn.microsoft.com/library/d...hor/dhtml/reference/dhtml_reference_entry.asp

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
 
Back
Top