网格视图中的按钮在更新面板中时会引起完整的回发

时间:2019-04-15 16:22:55

标签: c# asp.net ajax updatepanel

我有一个页面,其中包含4个网格视图,每个视图中都有一些按钮。此页面分为多个选项卡。我只想更新我要更新的特定标签,而不想要整个页面。现在,如果我单击第三页上的一个按钮,则会引起回发并将我重新加载到第一个标签中。我在更新面板中拥有所有选项卡以及每个选项卡。

我在更新面板中拥有所有选项卡以及每个选项卡。我尝试使用gridview中的按钮将触发器添加到第二个更新面板,但是它说它看不到该控件。

<div class="container ">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
                <ContentTemplate>
                    <br>
                    <h1 class="title1">Page Settings</h1>
                    <hr />


                    <!-- --------------------------------------------------------- Tabs --------------------------------------------------------- -->
                    <!-- Nav tabs -->
                    <ul class="nav nav-tabs" id="myTab" role="tablist">
                        <li class="nav-item">
                            <a class="nav-link active" id="URM-Tab" data-toggle="tab" href="#URM" role="tab" aria-controls="URM" aria-selected="true">Under Represent Minority </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" id="POI-Tab" data-toggle="tab" href="#POI" role="tab" aria-controls="POI" aria-selected="false">Programs of Interest</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" id="Event-Tab" data-toggle="tab" href="#EVT" role="tab" aria-controls="EVT" aria-selected="false">Event Type</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" id="AdminDash-Tab" data-toggle="tab" href="#ADM" role="tab" aria-controls="ADM" aria-selected="false">Admin Dashboard</a>
                        </li>
                    </ul>

                    <br />

                    <!-- --------------------------------------------------------- PoI --------------------------------------------------------- -->

                        <div class="tab-pane" id="POI" role="tabpanel" aria-labelledby="POI-Tab">
                            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                <ContentTemplate>
                                    <h3>Programs of Interest</h3>

                                    <div class="addEvent" style="text-align: right;">
                                        <button type="button" class=" plus myButton" name="btnAddProgram" data-toggle="modal" data-target="#AddPoIModal" id="btnAddProgram" runat="server"><i class='fas fa-plus'></i></button>
                                    </div>


                                    <!-- Modal -->
                                    <div class="modal fade" id="AddPoIModal" role="dialog">
                                        <div class="modal-dialog">

                                            <!-- Modal content-->
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <h4 class="modal-title">Add Record</h4>
                                                </div>
                                                <div class="modal-body" style="text-align: center;">
                                                    <div class="container" id="Container3">
                                                        <div class="form-row">
                                                            <div class="form-group col-sm-3"></div>
                                                            <div class="form-group col-sm-6">
                                                                <asp:Label for="txtProgramName" ID="lblProgramName" runat="server" Text="Program Name"></asp:Label>
                                                                <asp:TextBox ID="txtProgramName" runat="server" Class="form-control" Text=""></asp:TextBox>
                                                            </div>
                                                            <div class="form-group col-sm-6"></div>
                                                        </div>
                                                    </div>

                                                </div>
                                                <div class="modal-footer">
                                                    <asp:Button ID="btnCancelProgram" runat="server" type="button" class="myButton" Style="text-align: center;" data-dismiss="modal" Text="Cancel"></asp:Button>&nbsp;&nbsp;&nbsp;
                                            <asp:Button ID="btnCreateProgram" Text="Create Program" type="button" runat="server" class="myButton" Style="text-align: center;" OnClick="btnCreateProgram_Click" />
                                                </div>
                                            </div>
                                        </div>
                                    </div>


                                    <asp:GridView ID="gvProgramOfInterest" OnRowCommand="gvProgramOfInterest_RowCommand" runat="server" CssClass="gridBorderLines" HorizontalAlign="Center" GridLines="None" BorderStyle="None" AutoGenerateColumns="false" DataKeyNames="ProgramID" OnRowDataBound="gvProgramOfInterest_RowDataBound">
                                        <Columns>
                                            <asp:BoundField DataField="ProgramName" HeaderText="Program Name" />
                                            <asp:BoundField DataField="Active" HeaderText="Active" />
                                            <asp:TemplateField HeaderText="Change Status">
                                                <ItemTemplate>
                                                    <asp:Button class="myButton" type="button" runat="server" Text="Change Status" ID="btnEditProgramOfInterest" OnClick="btnEditProgramOfInterest_Click" />
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </asp:GridView>

                                </ContentTemplate>
                                  <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="btnEditProgramOfInterest" EventName="Click" />
                                  </Triggers>
                            </asp:UpdatePanel>
                        </div>

0 个答案:

没有答案