在客户端弹出并传递网格中选定行的值

发布于 2024-12-04 13:56:25 字数 1565 浏览 1 评论 0原文

<asp:Panel ID="EditPanel" runat="server" BackImageUrl="~/Light-Gray-Suede1.jpg"
            CssClass="style10" Visible="True" Style="position: absolute; left: 503px; top: 1681px;
            width: 411px; height: 280px; margin-right: 0px;">
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
            </asp:ToolkitScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
        <asp:TextBox ID="txt_EditExpiresBy" runat="server" ></asp:TextBox>
                        <asp:TextBox ID="txt_EditTitle" runat="server" ></asp:TextBox>
                    <asp:Button ID="btn_EditSave" runat="server" Text="Save" onclick="btn_EditSave_Click" />

                </ContentTemplate>
            </asp:UpdatePanel>
        </asp:Panel>

在网格视图中,我有这个按钮,当用户单击编辑按钮时,会弹出面板,并且它必须具有来自同一行的过期日期和响应日期。

  <asp:ImageButton ImageUrl="~/Styles/Images/Edit.jpg" CommandName="Edit" runat="server"
                                    ID="btnEdit" ToolTip="Edit Message"  />
 <asp:PopupControlExtender ID="Edit_PopupControlExtender" runat="server" DynamicServicePath=""
                            Enabled="True" ExtenderControlID="" TargetControlID="btnEdit" PopupControlID="EditPanel">
                        </asp:PopupControlExtender>

对于重定向,我传递这样的值 <%# Eval("Email", "SendMessage.aspx?Email={0}") %>。我使用该值来编写服务器端代码。但这如何在客户端完成。谢谢

<asp:Panel ID="EditPanel" runat="server" BackImageUrl="~/Light-Gray-Suede1.jpg"
            CssClass="style10" Visible="True" Style="position: absolute; left: 503px; top: 1681px;
            width: 411px; height: 280px; margin-right: 0px;">
            <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
            </asp:ToolkitScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
        <asp:TextBox ID="txt_EditExpiresBy" runat="server" ></asp:TextBox>
                        <asp:TextBox ID="txt_EditTitle" runat="server" ></asp:TextBox>
                    <asp:Button ID="btn_EditSave" runat="server" Text="Save" onclick="btn_EditSave_Click" />

                </ContentTemplate>
            </asp:UpdatePanel>
        </asp:Panel>

In the grid view I have this button, when the user clicks on the edit button the panel pops up and it has to have expireby and respondby date from the same row.

  <asp:ImageButton ImageUrl="~/Styles/Images/Edit.jpg" CommandName="Edit" runat="server"
                                    ID="btnEdit" ToolTip="Edit Message"  />
 <asp:PopupControlExtender ID="Edit_PopupControlExtender" runat="server" DynamicServicePath=""
                            Enabled="True" ExtenderControlID="" TargetControlID="btnEdit" PopupControlID="EditPanel">
                        </asp:PopupControlExtender>

For redirect I pass the value like this <%# Eval("Email", "SendMessage.aspx?Email={0}") %>. And using that value I do the server side code. But how this can be done in client side. Thanks

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

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

发布评论

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

评论(1

预谋 2024-12-11 13:56:25

以下是在弹出窗口中显示所选行数据的解决方法(我使用我的一个网络项目的中继器完成了此操作):

使用所选行数据设置文本框,然后通过调用 .show() 显示弹出窗口

<script type="text/javascript">
    function showPopupWithRowData(expiryBy, respondBy)
    {
        var txtExpiryBy = $get('<%= this.txt_EditExpiresBy.ClientID %>');
        var txtRespondBy = $get('<%= this.txt_EditTitle.ClientID %>');

        txtExpiryBy.value = expiryBy;
        txtRespondBy.value = respondBy;

        $find('<%= this.Edit_PopupControlExtender.ClientID %>').show();

        return false; 
    }
</script>

当单击网格内的按钮时调用 javascript showPopupWithRowData() 的标记

<!-- Note: Replace ColumnNameExpiry and ColumnNameRespond with the original column names -->
<!-- Also note return, since our javascript method always returns false, it will prevent a postback when the image button is clicked --> 
<asp:ImageButton ImageUrl="~/Styles/Images/Edit.jpg" CommandName="Edit" runat="server" ID="btnEdit" ToolTip="Edit Message" OnClientClick="javascript:return showPopupWithRowData(<%#Eval("ColumnNameExpiry")%>, <%#Eval("ColumnNameRespond")%>);"  />

Here is work around for displaying selected row's data in popup (i did it with repeater for one of my web project):

javascript to set textboxes with selected row data and then show popup by calling .show()

<script type="text/javascript">
    function showPopupWithRowData(expiryBy, respondBy)
    {
        var txtExpiryBy = $get('<%= this.txt_EditExpiresBy.ClientID %>');
        var txtRespondBy = $get('<%= this.txt_EditTitle.ClientID %>');

        txtExpiryBy.value = expiryBy;
        txtRespondBy.value = respondBy;

        $find('<%= this.Edit_PopupControlExtender.ClientID %>').show();

        return false; 
    }
</script>

markup to call javascript showPopupWithRowData() when clicked on button inside Grid

<!-- Note: Replace ColumnNameExpiry and ColumnNameRespond with the original column names -->
<!-- Also note return, since our javascript method always returns false, it will prevent a postback when the image button is clicked --> 
<asp:ImageButton ImageUrl="~/Styles/Images/Edit.jpg" CommandName="Edit" runat="server" ID="btnEdit" ToolTip="Edit Message" OnClientClick="javascript:return showPopupWithRowData(<%#Eval("ColumnNameExpiry")%>, <%#Eval("ColumnNameRespond")%>);"  />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文