Click here to Skip to main content
15,498,859 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Team i am just open a tab  with java script in c#
StringBuilder sb = new StringBuilder();
sb.Append("<script type = 'text/javascript'>");
Session["url"] = url.ToString();
"script", sb.ToString());
//this is f9 perfactly ...
and i want to close the open tab(url) after 40 seconds
how it possible
i am using
string jScript = "<script>window.close();</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "btnsubmit", jScript);
//this work with btnsubmit on any other form
but here  is  not working ..
i am just want to perform it with timer event or any other option you have please suggest..
Updated 28-Oct-20 4:54am

You are doing it wrong. You already use This call returns window object which you discard. But you can use it:
var someWindow =* ... */);

// ...


Share this answer
Aditya Chauhan 27-Mar-15 14:45pm    
how it declared in cod behind pls suggest ...?
Sergey Alexandrovich Kryukov 27-Mar-15 16:29pm     CRLF
It has nothing to do with code behind... Code behind does not remove pages, it only responds to HTTP requests and generates HTTP response. In a response, you can generate some text of a script, but manipulation with the pages can be done only by the script, on the client side. —SA
Aditya Chauhan 28-Mar-15 4:11am     CRLF
if it possible in the Php...why this not possible in i will provide you my credential for test it
Sergey Alexandrovich Kryukov 28-Mar-15 6:19am     CRLF
You are right. Moreover, it has nothing to do with code behind, no matter PHP or ASP.NET. :-) —SA
Do it in Javascript as part of the page script:
should do it
Share this answer
Aditya Chauhan 27-Mar-15 14:45pm     CRLF
how it is possible pls suggest me this is code behind code and i open a new tab as like how can i close it
You need to use:
string jScript = "<script>'', '_self', ''); window.close();</script>"
Share this answer
Dave Kreskowiak 28-Oct-20 11:52am     CRLF
You might want to look at the dates on questions before answering them. I seriously doubt the OP is still working on this 5 years later, and other answers have already covered the topic.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900