Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

C# TableCell Dynamic CSS Style and Event assignment PLEASE HELP

1 réponse
Avatar
jay.mistry
Hi,

I'm trying to make a page that has a dynamic menu on the left. I
generate this menu by getting the menu items from a database table
that holds title, alt tag, link, sort order, etc... for a given menu
ID. I had done a static version up until now and the number of pages
have gotten huge and this is why I decided to put menu info in the DB.
Right now I have a menus in a HTML Table with the following property
in every <TD> tag of every <TR> tag of the menu table:

<td height="20" class="gt0" nowrap onmouseenter="this.className='gt1'"
onmouseleave="this.className='gt0'">&nbsp;<font face="Arial,
Helvetica, sans-serif"><a
href="www.google.com">professional</a></font></td>

How can I do this in C#? I get the table entries and have something
along the lines of:

Table table = new Table();
while(datareader.Read()) {
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell....//set all properties
Hyperlink link = new Hyperlink();
link....//set all attributes of the link with data from DB
cell.add(link);
row.add(cell);
table.add(row);
}

How do I specify the event listed in the <TD> tag that is listed above
in the TableCell? i've fooled around a bit, but not having good books
and unable to find examples have left me to a last resort of posting
the problem...Any help would be really appreciated.

Thank you :)

Jay.

1 réponse

Avatar
jay.mistry
Hi all,

I've figured this out. Its via the Attributes property of any Web
Component. I just did something like

myCell.Attributes.Add("onmouseenter","this.classname'gt1'");
...

and it inserted those attributes.

Thanks anyways for your help.

(Jay) wrote in message news:...
Hi,

I'm trying to make a page that has a dynamic menu on the left. I
generate this menu by getting the menu items from a database table
that holds title, alt tag, link, sort order, etc... for a given menu
ID. I had done a static version up until now and the number of pages
have gotten huge and this is why I decided to put menu info in the DB.
Right now I have a menus in a HTML Table with the following property
in every <TD> tag of every <TR> tag of the menu table:

<td height="20" class="gt0" nowrap onmouseenter="this.className='gt1'"
onmouseleave="this.className='gt0'">&nbsp;<font face="Arial,
Helvetica, sans-serif"><a
href="www.google.com">professional</a></font></td>

How can I do this in C#? I get the table entries and have something
along the lines of:

Table table = new Table();
while(datareader.Read()) {
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell....//set all properties
Hyperlink link = new Hyperlink();
link....//set all attributes of the link with data from DB
cell.add(link);
row.add(cell);
table.add(row);
}

How do I specify the event listed in the <TD> tag that is listed above
in the TableCell? i've fooled around a bit, but not having good books
and unable to find examples have left me to a last resort of posting
the problem...Any help would be really appreciated.

Thank you :)

Jay.