Solved

Modal Window Close

Posted on 2006-07-04
7
268 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now