Solved

Modal Window Close

Posted on 2006-07-04
7
272 Views
Last Modified: 2006-11-18
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
0
Comment
Question by:radhakrishan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17036175
How are you opening the window ? Where is you code to close the window ?
0
 

Author Comment

by:radhakrishan
ID: 17036204
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
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
ID: 17036220
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:radhakrishan
ID: 17036304
Hi Carl,


Doing that, gives me a compiler error:

CS1026 ) Expected....
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17036320
Can you post the definition of your Button as you have it now ? And also the line that is causing the compile error ?
0
 

Author Comment

by:radhakrishan
ID: 17036341
<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
 

Author Comment

by:radhakrishan
ID: 17036364
I think I got the solution:

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

This works fine for me.

Cheers
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question