Modal Window Close

Hi Experts,


could anyone tell me, how to close a modal window on click of a button.

Using window.close does'nt seems to work.


Cheers
radhakrishanAsked:
Who is Participating?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
You might be better trying to add the code as a client-side click event on the button:

    <asp:Button runat="server" ID="Button1" onclick="javascript:window.close();" />
0
 
Carl TawnSystems and Integration DeveloperCommented:
How are you opening the window ? Where is you code to close the window ?
0
 
radhakrishanAuthor Commented:
Hi Carl,

The window is opened from another page and on click of a close button i wrote the following code:
(The click button is on the modal window page)

private void Button1_Click(object sender, System.EventArgs e)
            {
                string s1 = "<script>window.close();</script>";
                  Response.Write(s1);
            }
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
radhakrishanAuthor Commented:
Hi Carl,


Doing that, gives me a compiler error:

CS1026 ) Expected....
0
 
Carl TawnSystems and Integration DeveloperCommented:
Can you post the definition of your Button as you have it now ? And also the line that is causing the compile error ?
0
 
radhakrishanAuthor Commented:
<asp:Button id="Button1" style="Z-INDEX: 105; LEFT: 224px; POSITION: absolute; TOP: 216px" runat="server"
                        Width="96px" Text="Close" onclick="javascript:window.close();"></asp:Button>


And the highlighted line is the first line:

with same error CS1026 ) Expected.
0
 
radhakrishanAuthor Commented:
I think I got the solution:

this.Button1.Attributes.Add("onclick", "window.close(); return false;");

This works fine for me.

Cheers
0
All Courses

From novice to tech pro — start learning today.