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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening up a new window in ASP.Net

Status
Not open for further replies.

ac11nyc

Programmer
Oct 1, 2003
94
US
Can someone please tell me how to open up a new window once you click on a link. Also, i was wondering if its possible to remove all the explorer buttons from the new window besides a close window link button(in other words, only the information i want and a close window button)?
 
u can write onlick even of hyperlink. and call a function which uses javascript window.open method.,
if u want to hide make the controls run as server controls and u can tweek with visible and invisible properties.
good luck

something along these lines
<Script lan..=&quot;javascript&quot;>
finction funx(){
window.open(&quot;linkpath&quot;);
}
</script>
<a id=&quot;testlink&quot; onclick=&quot;funx&quot; href=&quot;....&quot;>openwindow here</a>
 
While still in this new or child window ... how do i refresh the parent window that opened it.

I tried
window.opener.document.forms(0).submit

... but it did not seem to refresh the parent window..
i also tried to call a function in the parent window but it di not work either ...

window.opener.CallTheFunction In ParentWindow()

pleaseeeeeee help!
 
There is no server method for opening a new window. Also, you can't (someone PLEASE CORRECT ME if I'm wrong/I'd dearly like to be wrong) have both a server-side event handler and a client-side event handler.

I had a situation where I wanted a form to be processed server-side, have the server-side event handler do some calculations, and the results displayed in a new window.

You have to use some sleight-of-hand.

First, recognized that creating a new window is a function of the browser, so the code for this has to be done client-side. JavaScript provides the &quot;window.open&quot; method. With hyperlinks, you can supply the &quot;target=_blank&quot; parameter.

The trick I've used is to process my form server_side, and at the end of the event handler proc, Response.Write() a complete script that performs the window.open method.

window.open takes three parameters, the URL, a window name, and a string of features/options to control the presentation of the window:

Code:
window.open('myURL','Popup window','toolbar=no,menubar=no')

A good link:
Thomas D. Greer
 
I don't know about removing the explorer buttons but if you change the target of a hyperlink to something like New it will open the hyperlinks URL into a new window.

Hope this helps.

Jennifer

Hope everyone is having a great day!

Thanks - Jennifer
 
Another option if you're using the Hyperlink WebControl is to set the Target property to _blank. No extra code required.

&quot;Also, you can't (someone PLEASE CORRECT ME if I'm wrong/I'd dearly like to be wrong) have both a server-side event handler and a client-side event handler.&quot;

Good news, Mr. Greer. You're wrong. P-) I just found out about the dual-side events myself!

I guess the preferred technique for creating client-side events is to create a JavaScript event in the page header, then add the event handler to the server control's attributes collection:

Code:
<!--In the .aspx file-->
<HEAD>
   <SCRIPT LANGUAGE = &quot;javascript&quot;>
      function btnMyButton_ClientClick()
      {
          alert( &quot;Client Event&quot; );
      }
   </SCRIPT>
</HEAD>



//in the code-behind
private void Page_Load( object sender, System.EventArgs e)
{
//add reference to client function for btnMyButton
   btnMyButton.Attributes.Add(&quot;OnClick&quot;, &quot;btnMyButton_ClientClick();&quot;);
}

In the case of a control having both a client- AND server-side event, the client event will, naturally, be handled first.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top