Last post Jan 25, 2017 07:02 PM by Gleeming
Jan 25, 2017 01:31 PM|Gleeming|LINK
When a button is pressed on my main web form MainPage.aspx I am displaying another Asp.net page "Results.aspx" as a popup window. It works,
and when my popup is displayed I have a "close" button on the page to close the popup window. The issue is that the user has to press the close button
twice before the popup window closes. One press will not close it. Below is basically my code. Does anyone know how I can fix the code so that I only
have to press the close button once in order for the popup window to close?
In MainPage.cs :
// In C# I build a Hyperlink control to display on my page :
Hyperlink myLink = new HyperLink();
newLink.Text = "Welcome Text";
In page being called as a popup Results.aspx:
In C# In Results.aspx :
void protected MyButton_Click(object sender, EventArgs e)
Page.ClientScript.RegisterOnSubmitStatement(typeof(Page), "closing", "window.unload=CloseWindow();");
in Results.aspx :
<base target="_self" />
Jan 25, 2017 06:23 PM|vineed_menon|LINK
I am assuming the following for my reply to you query
1. MyButton is the button on Results.aspx that you are using to close the popup.
2. On click of MyButton, you are only closing the dialog and not performing any other action that requires server side post.
If I am correct, then I would suggest the instead of Calling the CloseWindow after postback of the Results.aspx page, you can simply call the client side function directly using the following code
<asp:Button Id="MyButton" runat="server" Text="Close" OnClientClick="CloseWindow();" />
This would call the CloseWindow function immediately and should solve the problem reported.
Hope this helps
Jan 25, 2017 07:02 PM|Gleeming|LINK