asp.net - How to hide and visible an Image programmatically

show and hide Image programmatically
asp.net image server control lets you work with images in server side coding. so we can display images in web pages various way by .net framework. we can change the image source programmatically. we also can assign image border color, border style, image width, height dynamically. there are lots of facilty exists in asp.net image server control. this example demonstrate you how can we hide or show image from web pages programmatically. here we uses image visible property and assigning it's value true or false. run this code in your IDE and see how to manage image visibility feature programmatically.
ImageVisible.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Image1.Visible = false;
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        Image1.Visible = true;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to show, hide, visible Image programmatically</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">Image Example: Show Hide</h2>
        <asp:Image 
             ID="Image1" 
             runat="server"
             ImageUrl="~/Images/Birds2.jpg"
             BorderColor="SeaGreen"
             BorderWidth="3"
             BorderStyle="Inset"
             Height="300"
             />
        <br /><br />
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="MediumOrchid"
             Text="Hide Image"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="MediumOrchid"
             Text="Visible Image"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>
More asp.net examples