Jenniferggj
New Member
First of all, excuse my newness to ASP .net. I am sure a little more experience will allow me to not ask such basic questions.<BR><BR>I have a form on which I want to check the status of a checkbox (Check/Unchecked). When I put my sub in a Code-behind page, my form elements are "undefined". When I put the code in <Script> tags within the aspx page, I am able to check the status of the checkbox.<BR><BR><!-- Sub Code --><BR>Sub CheckBoxStatus(ByVal s As Object, ByVal e As EventArgs)<BR>'Check state of Checkbox<BR>If cb_myCheckBox.Checked Then<BR>lbl_Checked.Text = "Checked"<BR>Else<BR>lbl_Checked.Text = "Unchecked"<BR>End If<BR>End Sub<BR><!-- End --><BR><BR>Thankswhat does your code-behind class look like? post some codeAs Requested:<BR><BR>Public Class SearchForm<BR> Inherits System.Web.UI.Page<BR> Protected WithEvents SearchFormTabs As System.Web.UI.WebControls.Table<BR> Protected WithEvents BackgroundTable As System.Web.UI.WebControls.Table<BR> Protected WithEvents SearchFormAndButtons As System.Web.UI.WebControls.Table<BR><BR>#Region " Web Form Designer Generated Code "<BR><BR> 'This call is required by the Web Form Designer.<BR> <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<BR><BR> End Sub<BR><BR> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init<BR> 'CODEGEN: This method call is required by the Web Form Designer<BR> 'Do not modify it using the code editor.<BR> InitializeComponent()<BR> End Sub<BR><BR>#End Region<BR><BR> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR> 'Put user code to initialize the page here<BR> End Sub<BR><BR> Sub DisplayDocumentType_Date(ByVal s As Object, ByVal e As EventArgs)<BR> 'Check state of Checkbox<BR> If cb_DisplayDocumentType_Date.Checked Then<BR> lbl_Checked.Text = "Checked"<BR> Else<BR> lbl_Checked.Text = "Unchecked"<BR> End If<BR> End Sub<BR><BR>End ClassYou need to declare cb_DisplayDocumentType_Date and lbl_Checked as public variables of type checkbox and label, respectively, in your class. Scope should be global.Chris:<BR><BR>Like this?<BR><BR>Public Class SearchForm<BR> Inherits System.Web.UI.Page<BR> Protected WithEvents SearchFormTabs As System.Web.UI.WebControls.Table<BR> Protected WithEvents BackgroundTable As System.Web.UI.WebControls.Table<BR> Protected WithEvents SearchFormAndButtons As System.Web.UI.WebControls.Table<BR> Dim cb_DisplayDocumentType_Date As CheckBox<BR> Dim lbl_Checked As Label<BR><BR>As I said, this stuff is new to me. I have a class scheduled in the near future, but I want to get some sort of a start before the class.<BR><BR>ThanksPublic cb_DisplayDocumentType_Date As CheckBox<BR>Public lbl_Checked As Label<BR>Thanks a lot for your time and patience.<BR><BR>I appreciate them both.---- Code Behind -----<BR>Option Explicit On <BR><BR>Imports System<BR>Imports System.Web<BR>Imports System.Web.UI<BR>Imports System.Web.UI.WebControls<BR><BR>Public Class firstCB : Inherits Page<BR> Public lblHeader As Label<BR> Public chkTest As CheckBoxList<BR><BR> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)<BR> lblHeader.Text = "Label set From Code Behind<BR>The value of the checkbox list is " & _<BR> chkTest.Items(chkTest.SelectedIndex).Value<BR> End Sub<BR><BR>End Class<BR><BR><BR>--- Web Form ---<BR><%@ Page Language="vb" src=http://aspmessageboard.com/archive/index.php/"firstCB.vb" Inherits="firstCB"%><BR><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><BR><HTML><BR> <HEAD><BR> <title>WebForm1</title><BR> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"><BR> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0"><BR> <meta name="vs_defaultClientScript" content="JavaScript"><BR> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"><BR> </HEAD><BR> <body MS_POSITIONING="GridLayout"><BR> <form id="Form1" method="post" runat="server"><BR> <asp:Label ID="lblHeader" Runat="server" /><BR> <asp:CheckBoxList ID="chkTest" Runat="server"><BR> <asp:ListItem Value="1">One</asp:ListItem><BR> <asp:ListItem Value="2" Selected="True">Two</asp:ListItem><BR> <asp:ListItem Value="3">Three</asp:ListItem><BR> </asp:CheckBoxList><BR> </form><BR> </body><BR></HTML><BR>.How can I comment my <asp:Table> code? For example:<BR><BR><asp:Table ID="SearchFormAndButtons" Runat="Server" CssClass="SearchFormBackground" CellSpacing="0" CellPadding="2"><BR><asp:TableRow ID="tr_FormRow" Runat="server" CssClass="SearchForm"><BR><asp:TableCell ID="tc_FormCell" Runat="server" borderwidth=1><BR><!-- Search Form Contents <BR>Include Form File --><BR><!--#include virtual="commonsearch_formssearch_forms.aspx"--></asp:TableCell><BR></asp:TableRow><BR><asp:TableRow ID="tr_DocumentTypeAndRecordedDateLabel" Runat="server"><BR>***<BR>*** PROBLEM COMMENT IS LISTED IN <!-- --> BELOW<BR>***<BR><!-- Common Search Form Contents <BR>Create a Table Row/Cell that displays Show Document Type and Record Date and a Checkbox. This Checkbox will be used to set the Visibility property of tbl_DocumentTypeAndRecordedDate Table. This table displays the Document Type and Recorded Date form components. --><BR> <asp:TableCell ID="tc_DocumentTypeAndRecordedDateLabel" Runat="server" CssClass="SearchForm" ColumnSpan="3"><BR> <asp:CheckBox ID="cb_DisplayDocumentType_Date" Runat="server" <BR> Checked="True" OnCheckedChanged="DisplayDocumentType_Date" /><BR> Show Document Type and Record Date<BR> </asp:TableCell><BR> </asp:TableRow><BR></asp:Table><BR><BR>Returns:<BR><BR>Parser Error <BR>Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. <BR><BR>Parser Error Message: Literal content ('<!-- Create a Table Row that displays Document Type and Recorded Date form components. This table row's Visibilty property is set by the Checkbox cb_DisplayDocumentType_Date in the Table tbl_DocumentTypeAndRecordedDateLabel. -->') is not allowed within a 'System.Web.UI.WebControls.TableRowCollection' .<BR><BR>It appears that comments can be place within the TableCell tags, but not within TableRows. Is there any way I can comment a TableRow??<BR>