Is there anything special I need to do with a CheckBox control placed inside an Ajax Update Panel? I've use the update panel many times before with other .NET controls, but for some reason the CheckBox control isn't triggering it's oncheckedchanged event.
Here's what I have:
The trigger is defined by using the <asp:AsyncPostBackTrigger> element inside the
<Triggers> element of the
UpdatePanel control. (If you are editing the page in Visual Studio, you can create triggers by using the
UpdatePanelTrigger Collection Editor dialog box.)
Thanks for the suggestions, but nothing seems to work. When I select the checkbox, nothing happens. Then when I unselect it, the whole page posts back, eventhough my CheckBox control is in the update panel.
I think it has something to do with this code being contained in a user control, but I can't imagine why. Shouldn't it still post back to my code file asychronously?
Another thing I noticed: If I'm looking at the GUI, and I double click the CheckBox control, VS swtiches to my CheckedChaged event in the code behind. So it's obviously aware of the event code.
Thanks again
"Don't sweat the petty things, and don't pet the sweaty things"
- George Carlin
I have tried your codes on a new page and I added a ScriptManager. The result is there is no problem. CheckBox's text changed to "Hello" on AJAX postback.
Please make sure that there is no JS error icon on browser (bottom-left on IE7). If there is a JS error, it is possible that it was causing the issue.
HTH
Ferry
Please "Mark as Answer" if this post answers your question.
I am having a problem related to check boxes as well. I have a third-party dropdown checkbox list control I have been using for quite a while. Now I am trying to update my pages to use UpdatePanels but as soon as I wrap this control in an UpdatePanel the
checkbox lists no longer shows up. Any help would be greatly appreciated.
I experienced this same problem with a check box causing a full post back even though it was contained inside an ajax update panel. In this instance the check box control was located in a user control (.ascx) which was itself was embedded in an update panel
on another page.
After looking at the source generated from the runtime it was easy to determine the problem.
Although I had set the "ClientIDMode" of the check box to static, the code generated in anticipation of the click event was done using the name mangling technique VS uses to prevent id collissions.
For me, I simply set the clientIDmode back to "Inherit" and it worked as desired.
I'm not sure is this is a problem with check box on update panel within an update panel or if it is an actual bug but this will solve the problem.
However I can see for those of you who really need the element id to be known, client side / javascript, it could be a huge headache.
barryman9000
Participant
1698 Points
605 Posts
CheckBox Control in Ajax Update Panel
Apr 30, 2008 07:35 PM|LINK
Is there anything special I need to do with a CheckBox control placed inside an Ajax Update Panel? I've use the update panel many times before with other .NET controls, but for some reason the CheckBox control isn't triggering it's oncheckedchanged event. Here's what I have:
<span style="position:relative; left:410px; top:0px"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:CheckBox ID="_cbTrack" runat="server" Text="Track Carrier" CssClass="sectionHdrNorm" AutoPostBack="true" Visible="true" oncheckedchanged="_cbTrack_CheckedChanged" /> </ContentTemplate> </asp:UpdatePanel> </span>And the Code Behind (not what I'm really trying to do, just a test):
Any help is appreciated, this one has me stumped.- George Carlin
letscode
Member
547 Points
96 Posts
Re: CheckBox Control in Ajax Update Panel
Apr 30, 2008 11:48 PM|LINK
Strange. Your code looks fine.
Is your PageLoad getting hit. Are you getting a Javascript error?
Rules to Successful Projects,..
chetan.sarod...
All-Star
65619 Points
11118 Posts
Re: CheckBox Control in Ajax Update Panel
May 02, 2008 03:32 AM|LINK
Use trigger for CheckBox
<asp:UpdatePanel ...>
<ContentTemplate>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="_cbTrack" />
</Triggers>
</asp:UpdatePanel>
The trigger is defined by using the <asp:AsyncPostBackTrigger> element inside the <Triggers> element of the UpdatePanel control. (If you are editing the page in Visual Studio, you can create triggers by using the UpdatePanelTrigger Collection Editor dialog box.)
http://asp.net/ajax/documentation/live/ViewSample.aspx?sref=UpdatePanelWalkthrough2%23TriggersDeclarativeMarkupCS.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
barryman9000
Participant
1698 Points
605 Posts
Re: CheckBox Control in Ajax Update Panel
May 02, 2008 06:50 PM|LINK
Thanks for the suggestions, but nothing seems to work. When I select the checkbox, nothing happens. Then when I unselect it, the whole page posts back, eventhough my CheckBox control is in the update panel.
I think it has something to do with this code being contained in a user control, but I can't imagine why. Shouldn't it still post back to my code file asychronously?
Another thing I noticed: If I'm looking at the GUI, and I double click the CheckBox control, VS swtiches to my CheckedChaged event in the code behind. So it's obviously aware of the event code.
Thanks again
- George Carlin
ferrymeidian...
Member
500 Points
126 Posts
Re: CheckBox Control in Ajax Update Panel
May 03, 2008 05:35 PM|LINK
Hi,
I have tried your codes on a new page and I added a ScriptManager. The result is there is no problem. CheckBox's text changed to "Hello" on AJAX postback.
Please make sure that there is no JS error icon on browser (bottom-left on IE7). If there is a JS error, it is possible that it was causing the issue.
HTH
Ferry
Regards,
Ferry Meidianto
www.meidianto.com
sands904
Member
4 Points
29 Posts
Re: CheckBox Control in Ajax Update Panel
May 13, 2009 03:48 PM|LINK
I am having a problem related to check boxes as well. I have a third-party dropdown checkbox list control I have been using for quite a while. Now I am trying to update my pages to use UpdatePanels but as soon as I wrap this control in an UpdatePanel the checkbox lists no longer shows up. Any help would be greatly appreciated.
Website Design - Stephanie's Web Design
Software for Dog Professionals - DogBizPro
adarshtated
Member
202 Points
51 Posts
Re: CheckBox Control in Ajax Update Panel
Jun 23, 2010 11:58 AM|LINK
Hi
Please create one more page and test it . The above code is working fine their may be any other problem in your web page
Regards
Adarsh
nileshcpatka...
Member
18 Points
17 Posts
Re: CheckBox Control in Ajax Update Panel
Oct 29, 2010 01:08 PM|LINK
I tried it on another page also.Still textbox value not changed.
When I debug, control moves from content page load,master page load and then chekbox changed event.
But still messsage not reflected into text box.
pmoneyman
Member
2 Points
1 Post
Re: CheckBox Control in Ajax Update Panel
Nov 09, 2010 03:26 PM|LINK
I experienced this same problem with a check box causing a full post back even though it was contained inside an ajax update panel. In this instance the check box control was located in a user control (.ascx) which was itself was embedded in an update panel on another page.
After looking at the source generated from the runtime it was easy to determine the problem.
Although I had set the "ClientIDMode" of the check box to static, the code generated in anticipation of the click event was done using the name mangling technique VS uses to prevent id collissions.
For me, I simply set the clientIDmode back to "Inherit" and it worked as desired.
I'm not sure is this is a problem with check box on update panel within an update panel or if it is an actual bug but this will solve the problem.
However I can see for those of you who really need the element id to be known, client side / javascript, it could be a huge headache.
nileshcpatka...
Member
18 Points
17 Posts
Re: CheckBox Control in Ajax Update Panel
Nov 11, 2010 11:30 AM|LINK
The issue has been resolved.I used Script Manager at the top and put all controls inside the Update panel which I want to reflect.
e.g.If I want to fill gridView on Drop down of selected index changed event then gridView as well as drop down in same update panel/content template.