stellyuk
asked on
Closing Browser Window C#
Hey there,
I was wondering if I could get a browser window to close using a button (using onclick event) in C#, if not how would I do this??
Stelly
I was wondering if I could get a browser window to close using a button (using onclick event) in C#, if not how would I do this??
Stelly
In the onclick event of your button in the .aspx code I think you just need to add window.close()
Something like this...
<asp:button onclick="window.close();" />
I don't have the ability to test this but I'm pretty sure it should work.
Something like this...
<asp:button onclick="window.close();" />
I don't have the ability to test this but I'm pretty sure it should work.
This should work:
<input type="button" value="Close Window" onclick="window.close()">
<input type="button" value="Close Window" onclick="window.close()">
Yes, that might be what I meant -- like I said, I couldn't test it as I don't have .Net compiler handy :(
Response.Write("<script>wi ndow.close ()</script >");
should also do.
Its was also there in the link i provided before.
should also do.
Its was also there in the link i provided before.
btnClosef.Attributes("oncl ick") = "javascript:return closeform()"
and in ur javascript
function closeform()
{
window.close();
return false;
}
and in ur javascript
function closeform()
{
window.close();
return false;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Note:
If you add the attribute in the code behind, this should be done in the Page_Load event so that it's there the first time you click the button, not in the Click event of the button.
If you add the attribute in the code behind, this should be done in the Page_Load event so that it's there the first time you click the button, not in the Click event of the button.
check out:
http://forums.devx.com/archive/index.php/t-9129.html