Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Doan Tran   on Apr 07 In Asp.net Category.

  
Question Answered By: Adelinda Fischer   on Apr 07

All your server  code does it send it to the browser.

To open  a new window  that side you HAVE to tell it to do it from javascript.

There are ways to do it so it "looks" like server code  is doing it.

You can write a server control  that outputs the required javascript along with the url.

Or you can Add attributes to a server control or an existing "off the shelf" control.

But all in all - IT HAS TO BE JAVASCRIPT that does the deed.

At teh end of the day you might as well turn your script below into a function and manually put it at teh top of you aspx  page - calling via hrefs.


<script>
function openit(mypage){
"window.open
(mypage,null,"height=200,width=400,status=yes,toolbar=no,menu
bar=no,location=no");"
}
</script>

called via hrefs like
<a href=javascript:void(0) onclick=openit("anypage.aspx")>OpenIt</a>
or
<a href=javascript:openit("anypage.aspx")>OpenIt</a>

Where the href itself can be genearted from server code via a Linklabel or a Label or something.

At the end of the day .... if you do supply the javascript function along with every href you throw out you will have reprodctions of it scattered throughout your code. If you don't want that then you'll have to tag the first instance it is outputted and then don't ouput it again.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Opening a new Window from ASP.NET code-behind Or get search suggestion and latest updates.


Tagged: