Wednesday, March 21, 2012

Partial page update question

Why isn't this section of code not calling mychkShowLegend_CheckedChanged in my code behind? I can put the same code that changes the visible to true/false based on checked in my PageLoad, and it works...otherwise, I take it out of the PageLoad and just leave it in thechkShowLegend_CheckedChanged and it doesn't work. Here's my code:
 <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:CheckBox ID="chkShowLegend" runat="server" AutoPostBack="True" Text="Notification Legend" />  <asp:Panel ID="Legend" runat="server" Visible="false"> <div id="lblLegend" style="Z-INDEX: 3; WIDTH: 477px; HEIGHT: 115px; border: solid 1px; padding-right: 5px; padding-left: 7px; padding-bottom: 5px; padding-top: 5px;" align="left" runat="server"> <font face="Arial" size="4"> <span style="font-size: 10pt;"> <span style="color: black"><strong>Black Text</strong></span> - Interval value received; operating environment normal<br /> <span style="color: gray"><strong>Gray Text</strong></span> - Interval value not received; previous valid interval substituted<br /> <span style="color: royalblue"><strong>Blue Text</strong></span> - Setpoint has changed from previous interval value<br /> <span style="color: crimson"><strong>Red Text</strong></span> - OOME for this interval<br /> <span style="color: darkorange"><strong>Orange Text</strong></span> - SCADA value is out of range compared to setpoints<br /> <span style="color: forestgreen"><strong>Green Text</strong></span> - LIP value has a different sign (+/-) compared to previous interval<br /> *Please check above indicators for current interval; multiple indicators are possible </span> </font> </div> </asp:Panel> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="chkShowLegend" EventName="CheckedChanged" /> </Triggers> </asp:UpdatePanel>In my code behind: protected void chkShowLegend_CheckedChanged(object sender, EventArgs e) { if (chkShowLegend.Checked) Legend.Visible = true; else Legend.Visible = false; }

I have tried your code, its working perfectly for me without any modification to your code.

canyou try by removing <triggers> section of update panel sincechkbox is inside the updatepanel it will automatically taken as atrigger(since childrenastriggers property of updatepanel is havingdefault value "true").

Some references.

Isuppose you are using other update panels alose on the page. which maycausing the issue.In that case its better if you can put the completepage code so that we can look into that.

Removing the trigger section worked perfectly. I do have multiple update panels on this page and I was wondering if that was causing problems; the other two have timers as triggers, a 1 second timer and a 30 second timer.

Thanks for the help!

No comments:

Post a Comment