Question

I have a button which causes a popup to be created:

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

The panel that pop's up has a gridview and when the button is pressed a SQL parameter is passed. :

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();
    }
}

The issue is that the gridview isn't showing because there is no postback to the server. When you add a button to ajaxToolkit:ModalPopupExtender the postback is pevented. How do I get it back?

Was it helpful?

Solution

You can force postback with Javascript by attaching __doPostBack to an event.

function doClick(sender, e) { 
__doPostBack(sender,e); 
} 

OTHER TIPS

Hi i use this code Javascript to close the popup and refresh parent webform

    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)

this could help you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top