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

时间:2011-09-14 15:52:24

标签: c# asp.net popup updatepanel ajaxcontroltoolkit

<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>

对于重定向,我传递的值如下所示&lt;%#Eval(“Email”,“SendMessage.aspx?Email = {0}”)%&gt;。并使用该值我做服务器端代码。但是如何在客户端完成这项工作。感谢

1 个答案:

答案 0 :(得分:0)

这是解决方法在弹出窗口中显示所选行的数据(我使用我的一个web项目的转发器做了):

javascript设置包含所选行数据的文本框,然后通过调用.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")%>);"  />