1

I created collapsible and contant buttons in code behind. The contant contains text and button that call a function after click. The collapsible and the contant added to a place holder. The button in the contant should call to a function after click but instead he disappear with the rest of the created collapsible and contant buttons that created in code behind.

I tried to add return flase to the button onclick function. Also tried to define type=button but I need the button will be asp button and it always defined as a submit button. I put breakpoint at the start of the function but it doesn't even get there.

The html code: (also put there a static button for checking)

<asp:UpdatePanel ID="up1" runat="server">
                                    <ContentTemplate>
                                        <asp:Label ID="classesTypeSubject" runat="server" CssClass="card-text"><u>Class list</u></asp:Label>
                                        <PlaceHolder id="class_picker" runat="server" style="height: 200px; min-width: 150px; overflow: hidden; overflow-y: scroll;">
                                            <button class="collapsible" type="button">Cardio training</button>
                                            <div class="content">
                                                <p>
                                                    <u style="font: bold">Trainer:</u><asp:Label ID="trainer" runat="server" CssClass="card-text">Dolev Bastiker</asp:Label>
                                                    <br />
                                                    <u style="font: bold">Date:</u><asp:Label ID="date" runat="server" CssClass="card-text">22/06/19</asp:Label>
                                                    <br />
                                                    <u style="font: bold">Time:</u><asp:Label ID="time" runat="server" CssClass="card-text">18:00</asp:Label>
                                                    <asp:Button runat="server" Text="Sign to Cardio - 18:00" OnClick="Assinment_Click" Style="float: right" CssClass="btn btn-primary" />
                                                </p>
                                            </div>
                                        </PlaceHolder>
                                    </ContentTemplate>
                                </asp:UpdatePanel>

The code behind of buttons creation:

Button lesAssignmentButton = new Button();
                lesAssignmentButton.Text = "Sign to " + temp.getName() + " - " + temp.getTime();
                lesAssignmentButton.Attributes.Add("runat", "server");
                lesAssignmentButton.Attributes.Add("onClick", "Assinment_Click");
                lesAssignmentButton.Attributes.Add("style", "float: right");
                lesAssignmentButton.Attributes.Add("class", "btn btn-primary");

The expected result is a dynamic list of collapsible and contant buttons when the button in the contact section should activate a function.

skoobi
  • 11
  • 1
  • See for more https://www.google.nl/search?ei=gm09Xaf2L43fkgXc1pw4&q=dynamic+control+disappears+after+postback+site%3Astackoverflow.com&oq=dynamic+control+disappears+after+postback+site%3Astackoverflow.com&gs_l=psy-ab.3...1270.10582..10882...4.0..0.120.1377.26j1......0....1..gws-wiz.......0i22i30j33i160.UN5HZwhwDYc&ved=0ahUKEwinv4OCqdfjAhWNr6QKHVwrBwcQ4dUDCAo&uact=5 – VDWWD Jul 28 '19 at 09:42

0 Answers0