Solved

Example code using 'System.Web.UI.HtmlControls.HtmlInputCheckBox'

Posted on 2010-09-01
2
638 Views
Last Modified: 2013-12-17
Hi, I need your help on how to use the 'System.Web.UI.HtmlControls.HtmlInputCheckBox'  in codebehind.
Please provide me an example:
0
Comment
Question by:PagodNaUtak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
enzogoy earned 500 total points
ID: 33583078
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33583665
Hi,

Check code.

Regards,
VSS

---------------
//Default.aspx
---------------
<<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server" method="post">
        <div>            
            <asp:Button ID="btnTest" runat="server" Text="Test" OnClick="btnTest_Click" />
            <input type="Checkbox" id="inChkBox" runat="server" value="yes" title="yes" /><asp:Label ID="lblResult" Text="yes" runat="Server"/>          
        </div>
    </form>
</body>
</html>

-----------------
//Default.aspx.cs
------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
         
    }
    protected void btnTest_Click(object sender, EventArgs e)
    {
        HtmlInputCheckBox chk = (HtmlInputCheckBox)this.FindControl("inChkBox");

        if (chk.Value=="yes")
        {
            lblResult.Text = "No";
        }
    }     
}

Open in new window

0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question