Senin, 02 September 2013

How to use Checked property of CheckBox Control

Checked property is shows that your checkbox is either checked or not .Take a one example for showing image when your checkbox is checked. algorithm of the example are:
-->Drop one CheckBox control to Webpage
-->Set AutoPostBack property is true. Because when your CheckBox is checked then your page request send to the server . After server response your business logic event handler should executed.

Example of Showing Image when your CheckBox is checked.


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

<!DOCTYPE html>

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        if (CheckBox1.Checked)
        {
            Image1.Visible = true;
        }
        else
        {
            Image1.Visible = false;
        }
     
     
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Checked Property</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" Text="Show Image" OnCheckedChanged="CheckBox1_CheckedChanged" />
        <br />
        <asp:Image ID="Image1" runat="server" Height="161px" ImageUrl="~/download.jpg" Visible="False" Width="175px" />
    </div>
    </form>
</body>
</html>

Output
How to use Checked property of CheckBox Control

Tidak ada komentar:

Posting Komentar