具有模式弹出扩展器的按钮的服务器端事件

发布于 2024-10-19 00:22:58 字数 1063 浏览 3 评论 0原文

我有一个按钮,我在上面调用一个模式弹出扩展器,它显示一个面板。下面是代码:

<asp:Button ID="btnOne" runat="server" Text="View " 
                                onclick=" btnOne_Click" />


<asp:Panel ID="test" CssClass="ModalWindow"  Width="100%"  ScrollBars="Both" runat="server">
          <table id="tblgv" width="100%">
            <tr>
                <td>
                    <asp:GridView ID="gvTwo" runat="server">
                    </asp:GridView>
                </td>
            </tr>
             <tr>
                <td>
                <asp:Button ID="btnPopUpCancel" runat="server" Text="Close" />
                </td>
            </tr>
          </table>
        </asp:Panel>

<asp:ModalPopupExtender ID="ModalPopupExtender1"  OkControlID="btnPopUpCancel" 
  TargetControlID=" btnOne " PopupControlID="test" runat="server">
</asp:ModalPopupExtender>

在面板中,我有一个网格视图。我希望当我单击按钮时 gridview 将被加载。但它没有发生,当我单击按钮时,它不会进入服务器端。

帮我解决一下。

I have a button on which I am calling a modal pop up extender which is showing a panel. Below is the code:

<asp:Button ID="btnOne" runat="server" Text="View " 
                                onclick=" btnOne_Click" />


<asp:Panel ID="test" CssClass="ModalWindow"  Width="100%"  ScrollBars="Both" runat="server">
          <table id="tblgv" width="100%">
            <tr>
                <td>
                    <asp:GridView ID="gvTwo" runat="server">
                    </asp:GridView>
                </td>
            </tr>
             <tr>
                <td>
                <asp:Button ID="btnPopUpCancel" runat="server" Text="Close" />
                </td>
            </tr>
          </table>
        </asp:Panel>

<asp:ModalPopupExtender ID="ModalPopupExtender1"  OkControlID="btnPopUpCancel" 
  TargetControlID=" btnOne " PopupControlID="test" runat="server">
</asp:ModalPopupExtender>

In the panel, I have a gridview. I want that when I click the button gridview will be loaded. But it is not happening, when I clicked on the button it is not going server side.

help me how to resolve it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暗恋未遂 2024-10-26 00:22:58

您的问题是 ModalPopup 显示客户端。

如果您要做什么(绑定 gridview),您需要触发到服务器的回发。

  1. 为 ModalPopup 添加虚拟目标

    < asp:Button runat="server" ID="HiddenTargetControlForModalPopup" style="display:none" />

  2. set TargetControlID="HiddenTargetControlForModalPopup"

  3. 在 btnOne_Click 事件中调用 ModalPopupExtender1.show()。

btnOne 现在将触发服务器端事件。您还应该将 Gridview 放入更新面板中,并将 btnOne 设置为 asyncpostback 触发器。

希望这会有所帮助。

Your problem is that the ModalPopup is showing Client side.

If you what to do stuff (bind the gridview) you need do trigger a postback to the server.

  1. add a dummy target for the ModalPopup

    < asp:Button runat="server" ID="HiddenTargetControlForModalPopup" style="display:none" />

  2. set TargetControlID="HiddenTargetControlForModalPopup"

  3. call ModalPopupExtender1.show() inside the btnOne_Click event.

btnOne will now trigger a serverside event. You should also put the Gridview inside a update panel and set btnOne at as asyncpostback trigger.

Hope this will help.

獨角戲 2024-10-26 00:22:58

您可以根据需要使用异步回发触发器或 PostBackTrigger。我想要这个网格视图 在更新面板中,您需要使用异步回发触发器。
如果您希望在单击按钮时重新加载该页面,则需要回发触发器并确保该控制按钮位于该更新面板内。
这是一个例子

<asp:UpdatePanel ID="UPDTree" runat="server">
            <ContentTemplate>

                <asp:LinkButton ID="lnkfaketree" runat="server"></asp:LinkButton>
                <asp:ModalPopupExtender ID="mpeTree" runat="server" BackgroundCssClass="modalBackground recharge" CancelControlID="btntreeclose" PopupControlID="paneltree" TargetControlID="lnkfaketree"></asp:ModalPopupExtender>
        <asp:Panel ID="paneltree" runat="server" Style="display: none">
            <div class="btn-group pull-right">
            </div>
            <div class="box box-primary">
                <div class="box-header with-border" style="padding: 3px; background-color: #14181a; font-weight: bolder">
                    <h3 class="box-title" style="color: white">Tree View</h3>
                    <div class="btn-group pull-right">
                        <asp:LinkButton ID="btntreeclose" runat="server" CssClass="fa fa-close" OnClick="btntreeclose_Click"></asp:LinkButton>
                    </div>
                </div>

                <div class="form-horizontal">
                    <div class="box-body">
                        <div id="chart_div" style="width: 1000px; height: 500px; overflow: auto">
                        </div>
                        <asp:Button id="BtnNext" runat="server" OnClick="selectHandler()" />
<asp:Button id="btn_Submit" runat="server" OnClick="selectHandler2()" />
                    </div>
                </div>
            </div>
        </asp:Panel>
            </ContentTemplate><Triggers>
                <asp:AsyncPostBackTrigger ControlID="BtnNext" EventName="Click" />
                <asp:PostBackTrigger ControlID="btn_Submit" />
            </Triggers>
        </asp:UpdatePanel>

You Can Use Asynchronous PostBack Trigger Or PostBackTrigger as per your need. Id want this Grid View In update panel you need to use Asynchronous PostBack Trigger.
and if you want that page to be reload at button click you need to have post back trigger and make sure that control button to be inside that update panel.
Here is an Example

<asp:UpdatePanel ID="UPDTree" runat="server">
            <ContentTemplate>

                <asp:LinkButton ID="lnkfaketree" runat="server"></asp:LinkButton>
                <asp:ModalPopupExtender ID="mpeTree" runat="server" BackgroundCssClass="modalBackground recharge" CancelControlID="btntreeclose" PopupControlID="paneltree" TargetControlID="lnkfaketree"></asp:ModalPopupExtender>
        <asp:Panel ID="paneltree" runat="server" Style="display: none">
            <div class="btn-group pull-right">
            </div>
            <div class="box box-primary">
                <div class="box-header with-border" style="padding: 3px; background-color: #14181a; font-weight: bolder">
                    <h3 class="box-title" style="color: white">Tree View</h3>
                    <div class="btn-group pull-right">
                        <asp:LinkButton ID="btntreeclose" runat="server" CssClass="fa fa-close" OnClick="btntreeclose_Click"></asp:LinkButton>
                    </div>
                </div>

                <div class="form-horizontal">
                    <div class="box-body">
                        <div id="chart_div" style="width: 1000px; height: 500px; overflow: auto">
                        </div>
                        <asp:Button id="BtnNext" runat="server" OnClick="selectHandler()" />
<asp:Button id="btn_Submit" runat="server" OnClick="selectHandler2()" />
                    </div>
                </div>
            </div>
        </asp:Panel>
            </ContentTemplate><Triggers>
                <asp:AsyncPostBackTrigger ControlID="BtnNext" EventName="Click" />
                <asp:PostBackTrigger ControlID="btn_Submit" />
            </Triggers>
        </asp:UpdatePanel>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文