ToolTip for Table cell ASP.NET

I have created a dynamic table using below code.It is only a part of my code.

if (i >= startNo && i <= endNo) {
        panelName.Controls.Add(new LiteralControl("<td style=background-color:lightblue; >&nbsp;</td>"));
} else {

        panelName.Controls.Add(new LiteralControl("<td>&nbsp;</td>"));
}

I need to show a popup/tooltip message if the color is lightblue. Could you please help me out to figure this out?

Output of the current program

Answer

You can use the title property of the td like folloiwng.

panelName.Controls.Add(
new LiteralControl("<td title='some title' style=background-color:lightblue; >&nbsp;</td>"));

To set some dynamic value from server, you can try like following.

  string someToolTip = "Got from DB";
  panelName.Controls.Add(
 new LiteralControl("<td title='" someToolTip  + "' " +  "style=background-color:lightblue; >&nbsp;</td>"));

Leave a Reply

Your email address will not be published. Required fields are marked *