ASP->ASP.NET conversion of window.open - C# newbie.

  • Thread starter Thread starter Frank Nero
  • Start date Start date
F

Frank Nero

In my ASP HTML code I have:

<a
href="javascript:popupWin=window.open('Start.asp','StartFromBeg','resizable'
);location.reload();">Click here to start.</a>

How to acomplish the same (creation of the new browser instance) inside C#
code-behind
LinkButton1_Click(object sender, System.EventArgs e)

function?

I know how to do that using Java Script and:

LinkButton1.Attributes.Add( "OnClick", "PopUpWindow();" );

but I was hoping to C# could open new browser without calling Java Script.


Thank you ,

Ryszard Antonczyk
 
Frank,

This can't be done. C# doesn't execute on the client side, just the
server side. ASP.NET is still creating markup which is sent down to the
browser.

You will basically have to do the same thing that you did before, which
is to write the javascript into the stream that will open the window. If
you are going to take advantage of the click event on the button though, it
is a more roundabout way of doing what you want. The reason for this is
that the click will be propogated back to the server, and then the server
will re-load the page with the script to open the window. If you attach the
click event to the click handler on the client, then the window opens
instantly.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top