put the image outside the table and call the following javascript onclick of the image like
<img id="img1" src="close.png" alt="Close" onclick="close123();" />
<script type="text/javascript">
function close123() {
document.getElementById('table1').style.visibility = "hidden";
}
</script>
I think it should work
I have changed a bit in your code plz check
public static string GetDynamicContent(string contextKey)
{
string str = contextKey;
SqlConnection con;
SqlCommand cmd;
SqlDataReader reader;
DataTable table = new DataTable();
con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open();
cmd = new SqlCommand("select ReportDetails.hourNo, ReportDetails.fromtime, ReportDetails.toTime, ReportDetails.rptTime, ReportDetails.TaskDetails from ReportDetails Inner Join DailyReport on ReportDetails.DailyReport_ID = DailyReport.DailyReport_ID where DailyReport.DailyReport_ID = '" + contextKey + "' and user_id = '" + userid + "'", con);
reader = cmd.ExecuteReader();
table.Load(reader);
StringBuilder b = new StringBuilder();
b.Append("<table id = 'table2' style='background-color:#f3f3f3; border: #336699 3px solid; ");
b.Append("width:760px; font-size:8pt; font-family:Verdana;' cellspacing='0' cellpadding='2'>");
b.Append("<tr><td colspan='4' align = 'left' font-size:20pt; style='background-color:#336699; color:white;'>");
b.Append("<b>Reprort Details</b></td>"); b.Append("</td>");
b.Append("<td align = 'right' style='background-color:#336699; color:white;'><img id = 'img_11' style='border-width:0px;' src='red-ball.gif' onclick='javascript:close123()';></td>");
b.Append("</tr></table>");
b.Append("<table id = 'table1' style='background-color:#f3f3f3; border: #336699 3px solid; ");
b.Append("width:760px; font-size:8pt; font-family:Verdana;' cellspacing='0' cellpadding='2'>");
b.Append("<td align = 'left' font-size:10pt; style = 'width:80px; border:#336699 1px solid;'><b>Hour No<b></td>");
b.Append("<td align = 'left' font-size:10pt; style = 'width:80px; border:#336699 1px solid;'><b>Start Time</b></td>");
b.Append("<td align = 'left' font-size:10pt; style = 'width:80px; border:#336699 1px solid;'><b>End Time</b></td>");
b.Append("<td align = 'left' font-size:10pt; style = 'width:90px; border:#336699 1px solid;'><b>Report Time</b></td>");
b.Append("<td align = 'left' font-size:10pt; style = 'width:430px; border:#336699 1px solid;'><b>Activity</b></td>");
b.Append("</tr>");
int a = table.Rows.Count;
for (int i = 0; i < a; i++)
{
b.Append("<tr>");
b.Append("<td align = 'left' style = 'border:#336699 1px solid;'>" + table.Rows[i]["hourNo"].ToString() + "</td>");
b.Append("<td align = 'left' style = 'border:#336699 1px solid;'>" + table.Rows[i]["fromTime"].ToString() + "</td>");
b.Append("<td align = 'left' style = 'border:#336699 1px solid;'>" + table.Rows[i]["toTime"].ToString() + "</td>");
b.Append("<td align = 'left' style = 'border:#336699 1px solid;'>" + table.Rows[i]["rptTime"].ToString() + "</td>");
b.Append("<td align = 'left' style = 'border:#336699 1px solid;'>" + table.Rows[i]["TaskDetails"].ToString() + "</td>");
b.Append("</tr>");
}
b.Append("</table>");
return b.ToString();