Home All Groups Group Topic Archive Search About

ASP table background color

Author
22 Apr 2010 8:50 PM
mcolson
I have a table1 within a table2 within a form.  I would like to
progamatically change the color of table1 in my aspx.vb code based on
conditions.  How do I connect to the table's properties?

<form id="form1" runat="server">
    <div>

        <table class="style1">
            <tr>
                <td>
                    <table class="style1">
                        <tr>
                            <td style="background-color: #009900">
<<----- I neeed to change this.
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                    </table>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>

    </div>
    </form>

Author
22 Apr 2010 9:04 PM
Family Tree Mike
On 4/22/2010 4:50 PM, mcolson wrote:
Show quoteHide quote
> I have a table1 within a table2 within a form.  I would like to
> progamatically change the color of table1 in my aspx.vb code based on
> conditions.  How do I connect to the table's properties?
>
> <form id="form1" runat="server">
>      <div>
>
>          <table class="style1">
>              <tr>
>                  <td>
>                      <table class="style1">
>                          <tr>
>                              <td style="background-color: #009900">
> <<----- I neeed to change this.
>                                  &nbsp;</td>
>                              <td>
>                                  &nbsp;</td>
>                          </tr>
>                          <tr>
>                              <td>
>                                  &nbsp;</td>
>                              <td>
>                                  &nbsp;</td>
>                          </tr>
>                      </table>
>                  </td>
>                  <td>
>                      &nbsp;</td>
>              </tr>
>              <tr>
>                  <td>
>                      &nbsp;</td>
>                  <td>
>                      &nbsp;</td>
>              </tr>
>          </table>
>
>      </div>
>      </form>

You can add the attributes runat="server" id="MyCell", and then address
the cell from the server side, setting the BgColor property.  Your code
then would be MyCell.BgColor=Color.Red, as an example.

Out of curiosity, why are you using HTML tables rather than asp.net tables?

--
Mike
Author
23 Apr 2010 12:42 PM
mcolson
On Apr 22, 4:04 pm, Family Tree Mike <FamilyTreeM***@ThisOldHouse.com>
wrote:
Show quoteHide quote
> On 4/22/2010 4:50 PM, mcolson wrote:
>
>
>
> > I have a table1 within a table2 within a form.  I would like to
> > progamatically change the color of table1 in my aspx.vb code based on
> > conditions.  How do I connect to the table's properties?
>
> > <form id="form1" runat="server">
> >      <div>
>
> >          <table class="style1">
> >              <tr>
> >                  <td>
> >                      <table class="style1">
> >                          <tr>
> >                              <td style="background-color: #009900">
> > <<----- I neeed to change this.
> >                                  &nbsp;</td>
> >                              <td>
> >                                  &nbsp;</td>
> >                          </tr>
> >                          <tr>
> >                              <td>
> >                                  &nbsp;</td>
> >                              <td>
> >                                  &nbsp;</td>
> >                          </tr>
> >                      </table>
> >                  </td>
> >                  <td>
> >                      &nbsp;</td>
> >              </tr>
> >              <tr>
> >                  <td>
> >                      &nbsp;</td>
> >                  <td>
> >                      &nbsp;</td>
> >              </tr>
> >          </table>
>
> >      </div>
> >      </form>
>
> You can add the attributes runat="server" id="MyCell", and then address
> the cell from the server side, setting the BgColor property.  Your code
> then would be MyCell.BgColor=Color.Red, as an example.
>
> Out of curiosity, why are you using HTML tables rather than asp.net tables?
>
> --
> Mike

That may be a good question.  I've been tasked with building simple
page, but this is my first asp.net.  Kind of learning as I go.  I'll
look into the asp.net table.

Thanks.