Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have issue with the collapsible panel in my website. I have a check box beside to the text "School of the region" followed by the collapsible panel. When check the checkbox the panel needs to open automatically which is working fine and when I fill on the details in the collapsible panel and click on "save" button the panel must again collapse or close which is not working. The .aspx code is as follows

ASP.NET
<asp:PlaceHolder ID="phSchoolOfTheRegion" runat="server" Visible="false">
        <div class="styled sign-off">
            <fieldset>
                <div class="fright w300 margin-top-12">
                    <span class="margin-right-50">
                        <asp:Literal ID="LabeluxSchoolOfTheRegionCreated" runat="server"></asp:Literal></span>
                    <span>
                        <asp:Literal ID="LabeluxSchoolOfTheRegionRemoved" runat="server"></asp:Literal></span>
                </div>
                <ol class="margin-bottom-0 collapsible-checkbox-container">
                    <li class="header" style="float: left !important; width: 100% !important;">
                        <asp:CheckBox ID="uxSchoolOfTheRegion" runat="server" data-collapsiblepanel="uxDivSchoolOfTheRegion" CssClass="uxSignOffCollaps-1x" Text="School of the region" AutoPostBack="true" OnCheckedChanged="uxSchoolOfTheRegion_CheckedChanged" />
                    </li>
                </ol>
                <span class="signoff-collapse-head collapsible-heading">colapse</span>
                <div id="uxDivSchoolOfTheRegion" class="sign-off-form-wrapper showhide-heading">
                    <ol class="sign-off paddingLeft-20 margin-bottom-0">
                        <li>
                            <asp:Label runat="server" Text="State the decrease in car use and the dates:" AssociatedControlID="uxDecreaseCarUse"></asp:Label>
                            <asp:HiddenField ID="HiddenFieldSchoolOfTheRegionID" runat="server" />
                        </li>
                        <li>
                            <asp:RequiredFieldValidator ID="rvDecreaseCarUse" Enabled="true" ValidationGroup="SaveSchoolOfTheRegion" runat="server"
                                ErrorMessage="" Text="*" ControlToValidate="uxDecreaseCarUse" CssClass="required"><span>* Please state the decrease in car use and the dates</span></asp:RequiredFieldValidator>
                        </li>
                        <li>
                            <asp:TextBox ID="uxDecreaseCarUse" runat="server" MaxLength="100" ValidationGroup="SaveSchoolOfTheRegion"></asp:TextBox>
                        </li>
                        <li>
                            <asp:Label runat="server" Text="Top 3 achievements - what was the impact, who was affected, who participated?" AssociatedControlID="uxTop3Achievements"></asp:Label>
                        </li>
                        <li>
                            <asp:RequiredFieldValidator ID="rvTop3Achievements" Enabled="true" ValidationGroup="SaveSchoolOfTheRegion" runat="server"
                                ErrorMessage="" Text="*" ControlToValidate="uxTop3Achievements" CssClass="required">
                            <span>* Please state top 3 achievements - what was the impact, who was affected and who participated</span></asp:RequiredFieldValidator>
                        </li>
                        <li>
                            <asp:TextBox ID="uxTop3Achievements" runat="server" MaxLength="500" TextMode="MultiLine" Rows="5" CssClass="MultiLineTextArea"
                                data-span="uxTop3AchievementsCountdown" ValidationGroup="SaveSchoolOfTheRegion"></asp:TextBox>
                            <br />
                            <div class="width80p">
                                <span id="uxTop3AchievementsCountdown" class="countdown" style="float: right;">500 characters remaining.</span>
                            </div>
                        </li>
                        <li>
                            <asp:Label runat="server" Text="Why does the school deserve the award? Include information:" AssociatedControlID="uxWhyDeserveAward"></asp:Label>
                        </li>
                        <li>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Enabled="true" ValidationGroup="SaveSchoolOfTheRegion" runat="server"
                                ErrorMessage="" Text="*" ControlToValidate="uxWhyDeserveAward" CssClass="required">
                            <span>* Please state why does the school deserve the School Of The Region</span></asp:RequiredFieldValidator>
                        </li>
                        <li>
                            <asp:TextBox ID="uxWhyDeserveAward" runat="server" MaxLength="500" TextMode="MultiLine" Rows="5" CssClass="MultiLineTextArea"
                                data-span="uxWhyDeserveAwardCountdown" ValidationGroup="SaveSchoolOfTheRegion"></asp:TextBox>

                            <br />
                            <div class="width80p">
                                <span id="uxWhyDeserveAwardCountdown" class="countdown" style="float: right;">500 characters remaining.</span>
                            </div>
                        </li>
                        <li class="sign-off-button-row">
                            <p>
                                <asp:Button ID="btnSaveSchoolOfTheRegion" runat="server" Text="Save" CssClass="button" ValidationGroup="SaveSchoolOfTheRegion"
                                    OnClick="btnSaveSchoolOfTheRegion_Click" />
                            </p>
                            <p class="paddingLeft-20">
                                <asp:ValidationSummary ID="vsSaveSchoolOfTheRegion" ValidationGroup="SaveSchoolOfTheRegion" runat="server"
                                    HeaderText="Please complete all of the fields before saving." CssClass="alert validation CustomVs" />
                            </p>
                        </li>
                    </ol>
                </div>
            </fieldset>
        </div>
    </asp:PlaceHolder>


The .cs code is as follows

HTML
protected void btnSaveSchoolOfTheRegion_Click(object sender, EventArgs e)
   {
       if (Page.IsValid)
       {
           if (ValidateSchoolOfTheRegion())
           {
               if (uxSchoolOfTheRegion.Checked)
               {
                   try
                   {
                       SchoolOfTheRegion thisSchoolOfTheRegion = schoolOfTheRegionService.GetActiveEntryBySchoolId((int)SessionContents.CurrentSchool.SchoolID);

                       if (thisSchoolOfTheRegion != null)
                       {
                           thisSchoolOfTheRegion.IsSchoolOfTheRegion = uxSchoolOfTheRegion.Checked;
                           thisSchoolOfTheRegion.DecreaseInCarUsage = uxDecreaseCarUse.Text;
                           thisSchoolOfTheRegion.TopAchievements = uxTop3Achievements.Text;
                           thisSchoolOfTheRegion.WhyDeservesTheAward = uxWhyDeserveAward.Text;
                           schoolOfTheRegionService.Save(thisSchoolOfTheRegion);
                       }
                       else
                       {
                           SchoolOfTheRegion schoolOfTheRegion = new SchoolOfTheRegion();
                           schoolOfTheRegion.SchoolID = SessionContents.CurrentSchool.SchoolID;
                           schoolOfTheRegion.IsSchoolOfTheRegion = uxSchoolOfTheRegion.Checked;
                           schoolOfTheRegion.DecreaseInCarUsage = uxDecreaseCarUse.Text;
                           schoolOfTheRegion.TopAchievements = uxTop3Achievements.Text;
                           schoolOfTheRegion.WhyDeservesTheAward = uxWhyDeserveAward.Text;
                           schoolOfTheRegion.CreateDate = System.DateTime.Now;
                           schoolOfTheRegionService.Save(schoolOfTheRegion);
                       }

                   }

                   catch (Exception ex)
                   {
                       CustomValidator err = new CustomValidator();
                       err.ValidationGroup = "SaveSchoolOfTheRegion";
                       err.IsValid = false;
                       err.ErrorMessage = ex.Message + "<br/>" + ex.StackTrace;
                       Page.Validators.Add(err);
                   }
                   BindSchoolOfTheRegionAwardDates();
               }


           }
       }
   }
   protected void uxSchoolOfTheRegion_CheckedChanged(object sender, EventArgs e)
   {
       if (uxSchoolOfTheRegion.Checked != true)
       {
           SchoolOfTheRegion schoolOfTheRegion = schoolOfTheRegionService.GetActiveEntryBySchoolId((int)SessionContents.CurrentSchool.SchoolID);
           if (schoolOfTheRegion != null)
           {
               schoolOfTheRegion.IsSchoolOfTheRegion = false;
               schoolOfTheRegion.RemovedDate = System.DateTime.Now;
               if (schoolOfTheRegionService.Save(schoolOfTheRegion))
               {
                   uxSchoolOfTheRegion.Checked = false;
                   uxDecreaseCarUse.Text = string.Empty;
                   uxTop3Achievements.Text = string.Empty;
                   uxWhyDeserveAward.Text = string.Empty;
               }
           }
           BindSchoolOfTheRegionAwardDates();
       }
   }


Can anyone please help me to fix this issue.
Posted
Comments
Sreekanth Mothukuru 15-Jul-15 8:17am    
Do you see any errors in the web developer f12 console window?
user 3008 15-Jul-15 9:11am    
No I can't see any errors in the console window. When I click on the save the respective values are been stored in the database which means that the save button is working but the panel is not collapsing.If I can attach the screenshot I can do it but code project is supporting to attach the screenshot.
j snooze 15-Jul-15 17:44pm    
is your check box still checked after you click the save button? you said when you click this the panel opens up. Then you hit save...I would think the checkbox is still selected unless you tell it not to after postback?
user 3008 16-Jul-15 4:20am    
when the checkbox is unchecked the panel collapses and when it is checked the panel opens. When we click on the save button the checkbox is still in the checked state.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900