我有一个按钮,可以创建一个弹出窗口:
<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时,回发就被删除了。我如何取回它?
答案 0 :(得分:0)
您好我使用此代码Javascript关闭弹出窗口并刷新父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)
这可以帮到你
答案 1 :(得分:0)
您可以通过将__doPostBack
附加到某个活动来强制使用Javascript进行回发。
function doClick(sender, e) {
__doPostBack(sender,e);
}