Below is the javascript code found in the
head
tag:
<script type="text/javascript">
function HideDiv()
{
if (document.getElementById)
{
document.getElementById('myDiv').style.visibility = 'hidden';
}
else
{
if (document.layers)
{
document.hideShow.visibility = 'hidden';
}
else
{
document.all.hideShow.style.visibility = 'hidden';
}
}
}
function ShowDiv()
{
if (document.getElementById)
{
document.getElementById('myDiv').style.visibility = 'visible';
}
else
{
if (document.layers)
{
document.hideShow.visibility = 'visible';
}
else
{
document.all.hideShow.style.visibility = 'visible';
}
}
}
</script>
Below is the html code found in the
body
tag:
<img src="C:\myPic.jpg" onclick="ShowDiv()" width="100px" height="100px" />
<div id="myDiv" style="visibility:hidden; background-color:Blue; z-index:100" >
<asp:Label ID="lblQuestion" runat="server" Text="Do you want to delete image?"></asp:Label>
<asp:Button ID="btnYes" runat="server" Text="Yes" OnClick="btnYes_Click" />
<asp:Button ID="btnNo" runat="server" Text="No" OnClientClick="HideDiv()" />
</div>
Below is the C# code:
protected void btnYes_Click(object sender, EventArgs e)
{
System.IO.File.Delete("C:\\myPic.jpg");
}