Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close Current Window

Status
Not open for further replies.

JJBean1

IS-IT--Management
Sep 30, 2004
24
0
0
US
Hi,

How do I close the current window in Asp.net using C# in code?

Thanks,

JJ
 
vb, but you get the idea...
The double quotes in the right spots is important
Code:
    protected closeBtn As LinkButton
    protected myLiteral As Literal

    Sub closePage(sender As Object, e As EventArgs)
   	    Dim strjs as string = "<script language=""javascript"">"
 		strjs &= "window.close()"
  		strjs &= "</script" & ">"
		Literal1.Text = strjs
	End Sub
aspx page...
Code:
...
<asp:LinkButton id=closeBtn runat=server text=Close onClick=closePage />
<asp:Literal id=myLiteral runat=server />
...
 
make sure in the script you add
window.opener = this;
before window.close();

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top