0

我有一个按钮可以创建一个弹出窗口:

<ItemTemplate>
        <asp:Button ID="viewHoursButton" runat="server" Text="View Hours" OnClick="viewHoursButton_OnClick" />
        <ajaxToolkit:ModalPopupExtender ID="viewHoursPopup" runat="server"
                TargetControlID="viewHoursButton"
                PopupControlID="viewHoursPanel"
                CancelControlID="closeInfoPanelButton2"
                DropShadow="true">
                </ajaxToolkit:ModalPopupExtender>
    <asp:Panel ID="viewHoursPanel" runat="server" CssClass="infoPanel">
           //content of panel including gridview
    </asp:Panel>
</ItemTemplate>

弹出的面板有一个gridview,按下按钮时会传递一个SQL参数。:

protected void viewHoursButton_OnClick(object sender, EventArgs e)
{
    Button btn = sender as Button;
    GridViewRow row = btn.NamingContainer as GridViewRow;
    SqlDataSource6.SelectParameters["nonScrumStoryId"].DefaultValue = storyGridView.DataKeys[row.RowIndex].Values[0].ToString();
    var viewHoursGridView = storyGridView.FindControl("viewHoursGridView") as GridView;
    if (viewHoursGridView != null)
    {
        viewHoursGridView.DataBind();
    }
}

问题是 gridview 没有显示,因为没有回发到服务器。当您向 ajaxToolkit:ModalPopupExtender 添加一个按钮时,回发会被阻止。我该如何取回它?

4

2 回答 2

0

嗨,我使用此代码 Javascript 来关闭弹出窗口并刷新父 Web 表单

    Dim str_java As String = "<script language='javascript'>"
    str_java += (" window.onunload = refreshParent; ")
    str_java += (" function refreshParent() { ")
    str_java += (" window.self.location.reload(true); } ")
    str_java += (" window.close(); ")
    str_java += ("</script>")

    ScriptManager.RegisterStartupScript(Me, GetType(Page), "cerrarpagina", str_java, False)

这可以帮助你

于 2013-11-07T16:38:23.693 回答
0

__doPostBack您可以通过附加到事件来强制使用 Javascript 回发。

function doClick(sender, e) { 
__doPostBack(sender,e); 
} 
于 2013-11-07T16:38:52.147 回答