473,414 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

chechbox OnCheckChanged doesn't work!

Hi all,

Here's a matter I can't fix:
the method OnCheckedChanged 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="Shipping.aspx.cs"
Inherits="test" MaintainScrollPositionOnPostback="true" %>
<ajaxToolkit:ToolkitScriptManager EnablePartialRendering="true"
runat="Server" ID="ToolkitScriptManager1" />

<ajaxToolkit:Accordion ID="MyAccordion" runat="server"
SelectedIndex="0" HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent"
FadeTransitions="false" FramesPerSecond="1"
TransitionDuration="1" AutoSize="None"
RequireOpenedPane="true" SuppressHeaderPostbacks="false"
Width="900px" >

<ContentTemplate>

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

<asp:CheckBox ID="ManifestCheckBox"
runat="server" AutoPostBack="true"
Checked="True" OnCheckedChanged =
"ManifestCheckBox_CheckedChanged" />

</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</ajaxToolkit:Accordion>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:XXXXXXXXXXXXXXX %>"
SelectCommand="SELECT * FROM [tblPICManifest] WHERE ([PICBatchID] =
@PICBatchID)">
<SelectParameters>
<asp:ControlParameter ControlID="selectedLbl" DefaultValue=""
Name="PICBatchID"
PropertyName="Text" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

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

protected void Page_Load(object sender, EventArgs e)
{

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

protected void ManifestCheckBox_CheckedChanged(object sender, EventArgs e)
{
Control ctrSender = (Control)sender;
string controlID = ctrSender.ClientID;

............
}
--
ciao
Vittorix


Dec 19 '07 #1
3 1445
LVP
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" <vi******@gmail.comwrote in message
news:fk**********@tdi.cu.mi.it...
Hi all,

Here's a matter I can't fix:
the method OnCheckedChanged 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="Shipping.aspx.cs"
Inherits="test" MaintainScrollPositionOnPostback="true" %>
<ajaxToolkit:ToolkitScriptManager EnablePartialRendering="true"
runat="Server" ID="ToolkitScriptManager1" />

<ajaxToolkit:Accordion ID="MyAccordion" runat="server"
SelectedIndex="0" HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected"
ContentCssClass="accordionContent"
FadeTransitions="false" FramesPerSecond="1"
TransitionDuration="1" AutoSize="None"
RequireOpenedPane="true" SuppressHeaderPostbacks="false"
Width="900px" >

<ContentTemplate>

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

<asp:CheckBox ID="ManifestCheckBox"
runat="server" AutoPostBack="true"
Checked="True" OnCheckedChanged =
"ManifestCheckBox_CheckedChanged" />

</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</ajaxToolkit:Accordion>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:XXXXXXXXXXXXXXX %>"
SelectCommand="SELECT * FROM [tblPICManifest] WHERE ([PICBatchID] =
@PICBatchID)">
<SelectParameters>
<asp:ControlParameter ControlID="selectedLbl" DefaultValue=""
Name="PICBatchID"
PropertyName="Text" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

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

protected void Page_Load(object sender, EventArgs e)
{

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

protected void ManifestCheckBox_CheckedChanged(object sender, EventArgs e)
{
Control ctrSender = (Control)sender;
string controlID = ctrSender.ClientID;

............
}
--
ciao
Vittorix


Dec 19 '07 #2
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="true" and EnableViewState="true", the event is
triggered but when I select it is triggered with a wrong ClientID!
this is the problem

Vittorix
Dec 21 '07 #3
tried with AutoPostBack="true" and EnableViewState="true", the event is triggered but when I select it is triggered with a wrong ClientID!
this is the problem

Vittorix
Dec 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
39
by: Mark Johnson | last post by:
It doesn't seem possible. But would the following also seem a violation of the general notions behind css? You have a DIV, say asociated with class, 'topdiv'. Inside of that you have an anchor...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
4
by: bbp | last post by:
Hello, In an ASPX page I have a "Quit" button which make a simple redirect in code-behind. This button doesn't work no more since (I think) I moved from the framework 1.0 to 1.1 and it doesn't...
10
by: Sourcerer | last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to run it on my friend's computer (he doesn't have the compiler). We both have Windows XP Professional. I have .NET...
0
by: anupsonawane | last post by:
hi friends i want to add chechbox control in datagrid at runtime in vb.net 2005 so plz send me useful inf abt how to add this control at runtime & how to get check event on this checkbox....
6
by: Johnny Jörgensen | last post by:
I've got a usercontrol derived from a normal ComboBox that contains some special formatting code. On my main form I've got a lot of my custom comboboxes. I discovered a bug in the derived...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.