chechbox OnCheckChanged doesn't work!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vittorix

    #1

    chechbox OnCheckChanged doesn't work!

    Hi all,

    Here's a matter I can't fix:
    the method OnCheckedChange d is correctly fired when the checkbox is
    selectioned, but not when the checkbox is deselectioned! (the page just
    reloads)
    Please help, thanks in advance.

    I've an Ajax Accordion and a Repeater inside, both connected with a
    database.
    here is the fundamental structure:
    =============== =======aspx page=========== =============== ==============
    <%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Shipp ing.aspx.cs"
    Inherits="test" MaintainScrollP ositionOnPostba ck="true" %>


    <ajaxToolkit:To olkitScriptMana ger EnablePartialRe ndering="true"
    runat="Server" ID="ToolkitScri ptManager1" />

    <ajaxToolkit:Ac cordion ID="MyAccordion " runat="server"
    SelectedIndex=" 0" HeaderCssClass= "accordionHeade r"
    HeaderSelectedC ssClass="accord ionHeaderSelect ed"
    ContentCssClass ="accordionCont ent"
    FadeTransitions ="false" FramesPerSecond ="1"
    TransitionDurat ion="1" AutoSize="None"
    RequireOpenedPa ne="true" SuppressHeaderP ostbacks="false "
    Width="900px" >

    <ContentTemplat e>

    <asp:Repeater ID="Repeater1" runat="server"
    DataSourceID="S qlDataSource1">
    <ItemTemplate >

    <asp:CheckBox ID="ManifestChe ckBox"
    runat="server" AutoPostBack="t rue"
    Checked="True" OnCheckedChange d =
    "ManifestCheckB ox_CheckedChang ed" />

    </ItemTemplate>
    </asp:Repeater>
    </ContentTemplate >
    </ajaxToolkit:Acc ordion>

    <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
    ConnectionStrin g="<%$ ConnectionStrin gs:XXXXXXXXXXXX XXX %>"
    SelectCommand=" SELECT * FROM [tblPICManifest] WHERE ([PICBatchID] =
    @PICBatchID)">
    <SelectParamete rs>
    <asp:ControlPar ameter ControlID="sele ctedLbl" DefaultValue=""
    Name="PICBatchI D"
    PropertyName="T ext" Type="Int32" />
    </SelectParameter s>
    </asp:SqlDataSour ce>

    =============== =======aspx.cs code=========== =============== ==============

    protected void Page_Load(objec t sender, EventArgs e)
    {

    if (!IsPostBack)
    else
    {
    ............
    }

    protected void ManifestCheckBo x_CheckedChange d(object sender, EventArgs e)
    {
    Control ctrSender = (Control)sender ;
    string controlID = ctrSender.Clien tID;

    ............
    }


    --
    ciao
    Vittorix




  • LVP

    #2
    Re: chechbox OnCheckChanged doesn't work!

    From docs.
    A CheckBox control must persist some values between posts to the server for
    this event to work correctly. Be sure that view state is enabled for this
    control.

    The CheckedChanged event is raised when the value of the Checked property
    changes between posts to the server. This event does not post the page back
    to the server unless the AutoPostBack property is set to true.

    Occurs when the value of the Checked property changes between posts to the
    server.



    "Vittorix" <vittorix@gmail .comwrote in message
    news:fkbft6$d53 $1@tdi.cu.mi.it ...
    Hi all,
    >
    Here's a matter I can't fix:
    the method OnCheckedChange d is correctly fired when the checkbox is
    selectioned, but not when the checkbox is deselectioned! (the page just
    reloads)
    Please help, thanks in advance.
    >
    I've an Ajax Accordion and a Repeater inside, both connected with a
    database.
    here is the fundamental structure:
    =============== =======aspx page=========== =============== ==============
    <%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Shipp ing.aspx.cs"
    Inherits="test" MaintainScrollP ositionOnPostba ck="true" %>
    >
    >
    <ajaxToolkit:To olkitScriptMana ger EnablePartialRe ndering="true"
    runat="Server" ID="ToolkitScri ptManager1" />
    >
    <ajaxToolkit:Ac cordion ID="MyAccordion " runat="server"
    SelectedIndex=" 0" HeaderCssClass= "accordionHeade r"
    HeaderSelectedC ssClass="accord ionHeaderSelect ed"
    ContentCssClass ="accordionCont ent"
    FadeTransitions ="false" FramesPerSecond ="1"
    TransitionDurat ion="1" AutoSize="None"
    RequireOpenedPa ne="true" SuppressHeaderP ostbacks="false "
    Width="900px" >
    >
    <ContentTemplat e>
    >
    <asp:Repeater ID="Repeater1" runat="server"
    DataSourceID="S qlDataSource1">
    <ItemTemplate >
    >
    <asp:CheckBox ID="ManifestChe ckBox"
    runat="server" AutoPostBack="t rue"
    Checked="True" OnCheckedChange d =
    "ManifestCheckB ox_CheckedChang ed" />
    >
    </ItemTemplate>
    </asp:Repeater>
    </ContentTemplate >
    </ajaxToolkit:Acc ordion>
    >
    <asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
    ConnectionStrin g="<%$ ConnectionStrin gs:XXXXXXXXXXXX XXX %>"
    SelectCommand=" SELECT * FROM [tblPICManifest] WHERE ([PICBatchID] =
    @PICBatchID)">
    <SelectParamete rs>
    <asp:ControlPar ameter ControlID="sele ctedLbl" DefaultValue=""
    Name="PICBatchI D"
    PropertyName="T ext" Type="Int32" />
    </SelectParameter s>
    </asp:SqlDataSour ce>
    >
    =============== =======aspx.cs code=========== =============== ==============
    >
    protected void Page_Load(objec t sender, EventArgs e)
    {
    >
    if (!IsPostBack)
    else
    {
    ............
    }
    >
    protected void ManifestCheckBo x_CheckedChange d(object sender, EventArgs e)
    {
    Control ctrSender = (Control)sender ;
    string controlID = ctrSender.Clien tID;
    >
    ............
    }
    >
    >
    --
    ciao
    Vittorix
    >
    >
    >
    >

    Comment

    • Vittorix

      #3
      Re: chechbox OnCheckChanged doesn't work!

      LVP wrote:
      A CheckBox control must persist some values between posts to the
      server for this event to work correctly. Be sure that view state is
      enabled for this control.
      >
      The CheckedChanged event is raised when the value of the Checked
      property changes between posts to the server. This event does not
      post the page back to the server unless the AutoPostBack property is
      set to true.
      Occurs when the value of the Checked property changes between posts
      to the server.
      tried with AutoPostBack="t rue" and EnableViewState ="true", the event is
      triggered but when I select it is triggered with a wrong ClientID!
      this is the problem

      Vittorix


      Comment

      • Vittorix

        #4
        Re: chechbox OnCheckChanged doesn't work!

        tried with AutoPostBack="t rue" and EnableViewState ="true", the event is triggered but when I select it is triggered with a wrong ClientID!
        this is the problem

        Vittorix

        Comment

        Working...