Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dynamically creating <DIV> statement

Reply
Thread Tools

Dynamically creating <DIV> statement

 
 
Jennifer Mathews
Guest
Posts: n/a
 
      03-10-2009
' The <table> has two rows.
Dim oTbl As New Table
Dim oTR1 As New TableRow
Dim oTR2 As New TableRow
Dim oTD1 As New TableCell
Dim oTD2 As New TableCell

oTD1.Text = "Whatever One" ' Row 1
oTR1.Controls.Add(oTD1)
oTbl.Controls.Add(oTR1)

oTD2.Text = "Whatever Two" ' Row 2
oTR2.Controls.Add(oTD2)
oTbl.Controls.Add(oTR2)

plchld_One.Controls.Add(oTbl) ' plchld_One is a PlaceHolder control on the page.
' This all works fine.
' -------------------------------

' just changing the code above a bit.
Dim oPanl As New Panel
oPanl.ID = "myPanel"
oPanl.Visible = False

oTD2.Text = "Whatever Two" ' Row 2
oTR2.Controls.Add(oTD2)
oPanl.Controls.Add(oTR2) ' Add a PANEL ( = <div id="myPanel">) generates an error on
the next row.
oTbl.Controls.Add(oPanl) ' <<<<<<< 'Table' cannot have children of type 'Panel'.
' -------------------------------

' So the question is:
' How can I dynamically generate a <div> so I can Hide a row?

<table>
<tr>
<td>Whatever One</td>
</tr>
<div id="myPanel"> << how do I do this in CODE ?
<tr>
<td>Whatever Two</td>
</tr>
</div>
<table>


Thanks
~Jennifer~

 
Reply With Quote
 
 
 
 
sloan
Guest
Posts: n/a
 
      03-10-2009

The error looks correct to me: You can't just throw in a <div> in the
middle of a table.



This would be what you're after I think:



<table>
<tr>
<td>Whatever One</td>
</tr>

<tr><td>

<div id="myPanel">

</td></tr>


<tr>
<td>Whatever Two</td>
</tr>
</div>
<table>


"Jennifer Mathews" <> wrote in message
news:B57CBEAC-A3D3-4008-9746-...
>' The <table> has two rows.
> Dim oTbl As New Table
> Dim oTR1 As New TableRow
> Dim oTR2 As New TableRow
> Dim oTD1 As New TableCell
> Dim oTD2 As New TableCell
>
> oTD1.Text = "Whatever One" ' Row 1
> oTR1.Controls.Add(oTD1)
> oTbl.Controls.Add(oTR1)
>
> oTD2.Text = "Whatever Two" ' Row 2
> oTR2.Controls.Add(oTD2)
> oTbl.Controls.Add(oTR2)
>
> plchld_One.Controls.Add(oTbl) ' plchld_One is a PlaceHolder control on
> the page.
> ' This all works fine.
> ' -------------------------------
>
> ' just changing the code above a bit.
> Dim oPanl As New Panel
> oPanl.ID = "myPanel"
> oPanl.Visible = False
>
> oTD2.Text = "Whatever Two" ' Row 2
> oTR2.Controls.Add(oTD2)
> oPanl.Controls.Add(oTR2) ' Add a PANEL ( = <div id="myPanel">) generates
> an error on the next row.
> oTbl.Controls.Add(oPanl) ' <<<<<<< 'Table' cannot have children of type
> 'Panel'.
> ' -------------------------------
>
> ' So the question is:
> ' How can I dynamically generate a <div> so I can Hide a row?
>
> <table>
> <tr>
> <td>Whatever One</td>
> </tr>
> <div id="myPanel"> << how do I do this in CODE ?
> <tr>
> <td>Whatever Two</td>
> </tr>
> </div>
> <table>
>
>
> Thanks
> ~Jennifer~
>



 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      03-11-2009
this will not work, a div cannot span <td>'s

-- bruce (sqlwork.com)

sloan wrote:
> The error looks correct to me: You can't just throw in a <div> in the
> middle of a table.
>
>
>
> This would be what you're after I think:
>
>
>
> <table>
> <tr>
> <td>Whatever One</td>
> </tr>
>
> <tr><td>
>
> <div id="myPanel">
>
> </td></tr>
>
>
> <tr>
> <td>Whatever Two</td>
> </tr>
> </div>
> <table>
>
>
> "Jennifer Mathews" <> wrote in message
> news:B57CBEAC-A3D3-4008-9746-...
>> ' The <table> has two rows.
>> Dim oTbl As New Table
>> Dim oTR1 As New TableRow
>> Dim oTR2 As New TableRow
>> Dim oTD1 As New TableCell
>> Dim oTD2 As New TableCell
>>
>> oTD1.Text = "Whatever One" ' Row 1
>> oTR1.Controls.Add(oTD1)
>> oTbl.Controls.Add(oTR1)
>>
>> oTD2.Text = "Whatever Two" ' Row 2
>> oTR2.Controls.Add(oTD2)
>> oTbl.Controls.Add(oTR2)
>>
>> plchld_One.Controls.Add(oTbl) ' plchld_One is a PlaceHolder control on
>> the page.
>> ' This all works fine.
>> ' -------------------------------
>>
>> ' just changing the code above a bit.
>> Dim oPanl As New Panel
>> oPanl.ID = "myPanel"
>> oPanl.Visible = False
>>
>> oTD2.Text = "Whatever Two" ' Row 2
>> oTR2.Controls.Add(oTD2)
>> oPanl.Controls.Add(oTR2) ' Add a PANEL ( = <div id="myPanel">) generates
>> an error on the next row.
>> oTbl.Controls.Add(oPanl) ' <<<<<<< 'Table' cannot have children of type
>> 'Panel'.
>> ' -------------------------------
>>
>> ' So the question is:
>> ' How can I dynamically generate a <div> so I can Hide a row?
>>
>> <table>
>> <tr>
>> <td>Whatever One</td>
>> </tr>
>> <div id="myPanel"> << how do I do this in CODE ?
>> <tr>
>> <td>Whatever Two</td>
>> </tr>
>> </div>
>> <table>
>>
>>
>> Thanks
>> ~Jennifer~
>>

>
>

 
Reply With Quote
 
Logan S.
Guest
Posts: n/a
 
      03-11-2009
<Snip>

If your objective is to simply hide the row, you can do it this way:

<tr runat="server" ID="MyRow" Visible="true">...

Then, in the code-behind you can access the row as a server-side generic
html object, and set it's .visible property, like this:

MyRow.Visible = false;

Any time you add the runat="server" attribute to an HTML element, you can
then access it in your C# code-behind and control basic properties,
including .Visible.

HTH


 
Reply With Quote
 
Jennifer Mathews
Guest
Posts: n/a
 
      03-11-2009
Thanks to everyone for helping. A true education is starting.

"Jennifer Mathews" <> wrote in message
news:B57CBEAC-A3D3-4008-9746-...
>' The <table> has two rows.
> Dim oTbl As New Table
> Dim oTR1 As New TableRow
> Dim oTR2 As New TableRow
> Dim oTD1 As New TableCell
> Dim oTD2 As New TableCell
>
> oTD1.Text = "Whatever One" ' Row 1
> oTR1.Controls.Add(oTD1)
> oTbl.Controls.Add(oTR1)
>
> oTD2.Text = "Whatever Two" ' Row 2
> oTR2.Controls.Add(oTD2)
> oTbl.Controls.Add(oTR2)
>
> plchld_One.Controls.Add(oTbl) ' plchld_One is a PlaceHolder control on the page.
> ' This all works fine.
> ' -------------------------------
>
> ' just changing the code above a bit.
> Dim oPanl As New Panel
> oPanl.ID = "myPanel"
> oPanl.Visible = False
>
> oTD2.Text = "Whatever Two" ' Row 2
> oTR2.Controls.Add(oTD2)
> oPanl.Controls.Add(oTR2) ' Add a PANEL ( = <div id="myPanel">) generates an error on
> the next row.
> oTbl.Controls.Add(oPanl) ' <<<<<<< 'Table' cannot have children of type 'Panel'.
> ' -------------------------------
>
> ' So the question is:
> ' How can I dynamically generate a <div> so I can Hide a row?
>
> <table>
> <tr>
> <td>Whatever One</td>
> </tr>
> <div id="myPanel"> << how do I do this in CODE ?
> <tr>
> <td>Whatever Two</td>
> </tr>
> </div>
> <table>
>
>
> Thanks
> ~Jennifer~
>


 
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 statement that, when false, skips first statement in its block, executes second? Jay McGavren Java 11 01-16-2006 05:49 PM
How do I do a conditional statement in a constant statement? tkvhdl@gmail.com VHDL 3 12-16-2005 06:13 PM
Which of switch statement and if-else statement takes less time to execute? swaroophr@gmail.com C Programming 21 08-02-2005 09:24 AM
exec "statement" VS. exec "statement in globals(), locals() Ted Python 1 07-22-2004 08:51 AM
exec "statement" VS. exec "statement" in globals(), locals() tedsuzman Python 2 07-21-2004 08:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57