By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,002 Members | 1,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,002 IT Pros & Developers. It's quick & easy.

Help: Problem closing window

P: n/a
Joe
Hi,

I have a form with Submit and cancel button. When Cancel button is clicked I
want to close the browser window. Here is my sample form. To make things
simple I have removed the submit button. When I click on the cancel button,
the window doesn’t close. Can someone tell me what mistake I am making here?
Thanks for your help,

Joe

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("<script>self.close();<\/script>")
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" Runat="server" Text="Button"
OnClick="Button1_Click" />

</div>
</form>
</body>
</html>

Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You had a typo in your Response.Write line.
It should be this:
Response.Write("<script>self.close();</script>")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi,

I have a form with Submit and cancel button. When Cancel button is clicked
I
want to close the browser window. Here is my sample form. To make things
simple I have removed the submit button. When I click on the cancel
button,
the window doesn't close. Can someone tell me what mistake I am making
here?
Thanks for your help,

Joe

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("<script>self.close();<\/script>")
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" Runat="server" Text="Button"
OnClick="Button1_Click" />

</div>
</form>
</body>
</html>

Nov 19 '05 #2

P: n/a
Joe
Hi Steve,

If I use what you suggested -
Response.Write("<script>self.close();</script>") then I get an Compilation
error saying: String constants must end with a double quote.
with line highlighted
Response.Write("<script>self.close();</script>")

This error goes away when I use
Response.Write("<script>self.close();<\/script>")

Notice the escape sequence "\". Not I don't get the error but the window
doesn't close.

Joe
"Steve C. Orr [MVP, MCSD]" wrote:
You had a typo in your Response.Write line.
It should be this:
Response.Write("<script>self.close();</script>")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
Hi,

I have a form with Submit and cancel button. When Cancel button is clicked
I
want to close the browser window. Here is my sample form. To make things
simple I have removed the submit button. When I click on the cancel
button,
the window doesn't close. Can someone tell me what mistake I am making
here?
Thanks for your help,

Joe

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("<script>self.close();<\/script>")
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" Runat="server" Text="Button"
OnClick="Button1_Click" />

</div>
</form>
</body>
</html>


Nov 19 '05 #3

P: n/a
Have you tried window.close?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi Steve,

If I use what you suggested -
Response.Write("<script>self.close();</script>") then I get an Compilation
error saying: String constants must end with a double quote.
with line highlighted
Response.Write("<script>self.close();</script>")

This error goes away when I use
Response.Write("<script>self.close();<\/script>")

Notice the escape sequence "\". Not I don't get the error but the window
doesn't close.

Joe
"Steve C. Orr [MVP, MCSD]" wrote:
You had a typo in your Response.Write line.
It should be this:
Response.Write("<script>self.close();</script>")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
> Hi,
>
> I have a form with Submit and cancel button. When Cancel button is
> clicked
> I
> want to close the browser window. Here is my sample form. To make
> things
> simple I have removed the submit button. When I click on the cancel
> button,
> the window doesn't close. Can someone tell me what mistake I am making
> here?
> Thanks for your help,
>
> Joe
>
> <%@ Page Language="VB" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
>
> <script runat="server">
>
> Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Response.Write("<script>self.close();<\/script>")
> End Sub
> </script>
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:Button ID="Button1" Runat="server" Text="Button"
> OnClick="Button1_Click" />
>
> </div>
> </form>
> </body>
> </html>
>


Nov 19 '05 #4

P: n/a
Joe
Yup. Tried wind.close but same thing happens.

"Steve C. Orr [MVP, MCSD]" wrote:
Have you tried window.close?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi Steve,

If I use what you suggested -
Response.Write("<script>self.close();</script>") then I get an Compilation
error saying: String constants must end with a double quote.
with line highlighted
Response.Write("<script>self.close();</script>")

This error goes away when I use
Response.Write("<script>self.close();<\/script>")

Notice the escape sequence "\". Not I don't get the error but the window
doesn't close.

Joe
"Steve C. Orr [MVP, MCSD]" wrote:
You had a typo in your Response.Write line.
It should be this:
Response.Write("<script>self.close();</script>")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
> Hi,
>
> I have a form with Submit and cancel button. When Cancel button is
> clicked
> I
> want to close the browser window. Here is my sample form. To make
> things
> simple I have removed the submit button. When I click on the cancel
> button,
> the window doesn't close. Can someone tell me what mistake I am making
> here?
> Thanks for your help,
>
> Joe
>
> <%@ Page Language="VB" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
>
> <script runat="server">
>
> Sub Button1_Click(ByVal sender As Object, ByVal e As
> System.EventArgs)
> Response.Write("<script>self.close();<\/script>")
> End Sub
> </script>
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:Button ID="Button1" Runat="server" Text="Button"
> OnClick="Button1_Click" />
>
> </div>
> </form>
> </body>
> </html>
>


Nov 19 '05 #5

P: n/a
I'm not sure whats up but I use the same technique written a little diff. and
it always works.
Response.write "<script language=javascript>window.close()</script>"

Never had any trouble. I don't use the parenths on the write function. mabye
try that.

Good luck.

"Joe" wrote:
Yup. Tried wind.close but same thing happens.

"Steve C. Orr [MVP, MCSD]" wrote:
Have you tried window.close?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
Hi Steve,

If I use what you suggested -
Response.Write("<script>self.close();</script>") then I get an Compilation
error saying: String constants must end with a double quote.
with line highlighted
Response.Write("<script>self.close();</script>")

This error goes away when I use
Response.Write("<script>self.close();<\/script>")

Notice the escape sequence "\". Not I don't get the error but the window
doesn't close.

Joe
"Steve C. Orr [MVP, MCSD]" wrote:

> You had a typo in your Response.Write line.
> It should be this:
> Response.Write("<script>self.close();</script>")
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
>
> "Joe" <Jo*@discussions.microsoft.com> wrote in message
> news:E3**********************************@microsof t.com...
> > Hi,
> >
> > I have a form with Submit and cancel button. When Cancel button is
> > clicked
> > I
> > want to close the browser window. Here is my sample form. To make
> > things
> > simple I have removed the submit button. When I click on the cancel
> > button,
> > the window doesn't close. Can someone tell me what mistake I am making
> > here?
> > Thanks for your help,
> >
> > Joe
> >
> > <%@ Page Language="VB" %>
> >
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> >
> > <script runat="server">
> >
> > Sub Button1_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs)
> > Response.Write("<script>self.close();<\/script>")
> > End Sub
> > </script>
> >
> > <html xmlns="http://www.w3.org/1999/xhtml" >
> > <head runat="server">
> > <title>Untitled Page</title>
> > </head>
> > <body>
> > <form id="form1" runat="server">
> > <div>
> > <asp:Button ID="Button1" Runat="server" Text="Button"
> > OnClick="Button1_Click" />
> >
> > </div>
> > </form>
> > </body>
> > </html>
> >
>
>
>


Nov 19 '05 #6

P: n/a
Joe
falcon, I don't know how you are able to do witout paranthese because asp.net
should give you error.

Anyway when I tried this,

Response.Write("<script language=javascript>window.close()<" & "/script>")

I didn't get any errors and the window was closed too. WoW.

Thanks everybody for your time and help.

Joe

"falcon" wrote:
I'm not sure whats up but I use the same technique written a little diff. and
it always works.
Response.write "<script language=javascript>window.close()</script>"

Never had any trouble. I don't use the parenths on the write function. mabye
try that.

Good luck.

"Joe" wrote:
Yup. Tried wind.close but same thing happens.

"Steve C. Orr [MVP, MCSD]" wrote:
Have you tried window.close?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
> Hi Steve,
>
> If I use what you suggested -
> Response.Write("<script>self.close();</script>") then I get an Compilation
> error saying: String constants must end with a double quote.
> with line highlighted
> Response.Write("<script>self.close();</script>")
>
> This error goes away when I use
> Response.Write("<script>self.close();<\/script>")
>
> Notice the escape sequence "\". Not I don't get the error but the window
> doesn't close.
>
> Joe
>
>
> "Steve C. Orr [MVP, MCSD]" wrote:
>
>> You had a typo in your Response.Write line.
>> It should be this:
>> Response.Write("<script>self.close();</script>")
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>> "Joe" <Jo*@discussions.microsoft.com> wrote in message
>> news:E3**********************************@microsof t.com...
>> > Hi,
>> >
>> > I have a form with Submit and cancel button. When Cancel button is
>> > clicked
>> > I
>> > want to close the browser window. Here is my sample form. To make
>> > things
>> > simple I have removed the submit button. When I click on the cancel
>> > button,
>> > the window doesn't close. Can someone tell me what mistake I am making
>> > here?
>> > Thanks for your help,
>> >
>> > Joe
>> >
>> > <%@ Page Language="VB" %>
>> >
>> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
>> > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
>> >
>> > <script runat="server">
>> >
>> > Sub Button1_Click(ByVal sender As Object, ByVal e As
>> > System.EventArgs)
>> > Response.Write("<script>self.close();<\/script>")
>> > End Sub
>> > </script>
>> >
>> > <html xmlns="http://www.w3.org/1999/xhtml" >
>> > <head runat="server">
>> > <title>Untitled Page</title>
>> > </head>
>> > <body>
>> > <form id="form1" runat="server">
>> > <div>
>> > <asp:Button ID="Button1" Runat="server" Text="Button"
>> > OnClick="Button1_Click" />
>> >
>> > </div>
>> > </form>
>> > </body>
>> > </html>
>> >
>>
>>
>>

Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.