I create a div tag dynamically inside of a tag in C#(Asp.net) that will contain 3 dynamically generated buttons. I only want the div to display when the user mouses over the table cell(td tag). Can I acheive this throug .css?
The dynamic generation in C# looks like this:
HtmlTableCell cell = (HtmlTableCell)c;
HtmlInputButton PopupAddButton = new HtmlInputButton();
PopupAddButton.ID = "PBA" + c.ID.ToString();
PopupAddButton.Value = "Add";
PopupAddButton.Style["Height"] = "14px";
PopupAddButton.Style["Width"] = "40px";
PopupAddButton.Style.Add(HtmlTextWriterStyle.Top, "-100");
PopupAddButton.Style["right"] = "0";
PopupAddButton.Style["float"] = "left";
PopupAddButton.Style["vertical-align"] = "top";
PopupAddButton.Style["font-size"] = "9px";
HtmlInputButton PopupEditButton = new HtmlInputButton();
PopupEditButton.ID = "PBE" + c.ID.ToString();
PopupEditButton.Value = "Edit";
PopupEditButton.Style["Height"] = "14px";
PopupEditButton.Style["Width"] = "40px";
PopupEditButton.Style["top"] = "0";
PopupEditButton.Style["right"] = "0";
PopupEditButton.Style["float"] = "left";
PopupEditButton.Style["vertical-align"] = "top";
PopupEditButton.Style["font-size"] = "9px";
HtmlInputButton PopupDeleteButton = new HtmlInputButton();
PopupDeleteButton.ID = "PBD" + c.ID.ToString();
PopupDeleteButton.Value = "Delete";
PopupDeleteButton.Style["Height"] = "14px";
PopupDeleteButton.Style["Width"] = "40px";
PopupDeleteButton.Style["top"] = "0";
PopupDeleteButton.Style["right"] = "0";
PopupDeleteButton.Style["float"] = "left";
PopupDeleteButton.Style["font-size"] = "9px";
PopupDeleteButton.Style.Add(HtmlTextWriterStyle.VerticalAlign, "top");
PopupAddButton.Attributes.Add("onClick", "AddPopupControlToTableCell('" + cell.ClientID + "', '" + cell.Height.ToString() + "', '" + g_PopupControlId + "');");
PopupEditButton.Attributes.Add("onClick", "EditPopupControlToTableCell('" + cell.ClientID + "', '" + cell.Height.ToString() + "', '" + g_PopupControlId + "');");
PopupDeleteButton.Attributes.Add("onClick", "DeletePopupControlToTableCell('" + cell.ClientID + "', '" + cell.Height.ToString() + "', '" + g_PopupControlId + "');");
HtmlGenericControl ButtonDiv = new HtmlGenericControl("div");
ButtonDiv.ID = "buttonBlock" + c.ID.ToString();
ButtonDiv.Attributes.Add("class", "buttonBlock");
ButtonDiv.Controls.Add(PopupAddButton);
ButtonDiv.Controls.Add(PopupEditButton);
ButtonDiv.Controls.Add(PopupDeleteButton);
cell.Controls.Add(ButtonDiv);
my .css currently looks like this
.buttonBlock input{
display:none;
}
td:hover #buttonBlock input{
display:inline;
}
This does not work however. What am I doing incorrectly?
try fixing this code first
to
your original was looking for an id of buttonBlock (
#buttonBlock) when it should be looking for a class of buttonBlock (.buttonBlock)