Julie Gill

Julie Gill

  • NA
  • 3
  • 0

Checkbox event handler not firing

May 15 2007 7:37 AM
Hi, I've got a list of checkbox's that when the user selects/ deselects them the OnSelectedIndexChanged is fired and the value of the checkbox(s) should be copied into the listbox. However the eventhandler isn't being triggered. This is what I have so far: aspx page:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Questionnaire.aspx.cs" Inherits="Questionnaire" Title="Untitled Page" %>
aspx page:<br>
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Questionnaire.aspx.cs" Inherits="Questionnaire" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CandlesPlaceHolder" Runat="Server">
    <asp:CheckBoxList ID="CheckBoxList1" runat="server"  OnSelectedIndexChanged="CheckBoxList1_CheckedChanged" >
        <asp:ListItem Text="Presentation 1" Value="V:/projects/JG/PitchBook/PitchBook/Presentations/Test1.ppt"></asp:ListItem>
    </asp:CheckBoxList>
    <asp:CheckBoxList ID="CheckBoxList2" runat="server">
        <asp:ListItem Text="Presentation 2" Value="V:/projects/JG/PitchBook/PitchBook/Presentations/Test2.ppt"></asp:ListItem>
    </asp:CheckBoxList>
    <asp:ListBox ID="FileSelectedListBox" runat="server"></asp:ListBox>
    
</asp:Content>



cs file:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 Questionnaire : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void CheckBoxList1_CheckedChanged(object sender, EventArgs e)
    {
        //ListItem litem;
        //litem.Value = this.Items(
        object i;
        FileSelectedListBox.Text = "<p>Selected Items(s):</p>";
        for (int i = 0; i <= CheckBoxList1.Items.Count - 1; i++)

            if (CheckBoxList1.Items(i).Selected)
            {
                FileSelectedListBox.Text += CheckBoxList1.Items(i).Text + "<br />";
            }
        
        //FileSelectedListBox.Items.Add(CheckBoxList1.Text);
    }
}
<br>
Any help would be much appreciated...
<br>
Thanks J

Answers (1)