Opening a new browswer window using code behind

I have an ASP.NET application with the code behind written in C#. I'm trying to figure out how to open a new browser window when a user selects a menu option. Right now I have the command:


The problem is that this opens the pdf in the same browser window when, instead, I would like to open the pdf in a new browser window.

How can I do this?


2/13/2006 10:42:43 PM 24353 articles. 2 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 1
Get it on Google Play
Get it on Apple App Store

I am not sure what you mean by 'selects a menu option' - so I am presuming that you mean a button.

You cannot open a new window from the code behind as it is server side only. You can, however, attach some javascript that will open the window for you. The only problem with this is when the user has javascript disabled - in which case you should keep the code you have above.

e.g. (sorry, only know how to do this in, but the code should be easy enough to translate)

function PageLoad()
''The return false part stops a postback from happening.
myMenuButton1.attributes.add("onclick", "'documents/Emplyee.pdf'); return false;")
end function

Sub myMenuButton1 Handles myMenuButton1.Click
End Sub

Intelligence is a burden.
Jagdip Singh Ajimal
Manchester (and yes, I am a Manchester United fan)
2/14/2006 8:49:59 AM