Opening a new window from the code behind


On my web page I have a button which runs some code to update values. At the start of this code in the code behind I'd like to open another web page and another at the end of the updates but I can't work out how I do that. I've gota javascript statement on my client side code, do I need to do something similar on the code behind ?

Thanks for any help. 

2/28/2008 5:08:32 PM 24353 articles. 2 followers. Follow

4 Replies

Similar Articles

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


I assume someone clicks on the button on page 1?

Button1.Attributes.Add("onclick", "'Page2.aspx','popWin','width=300px,height=200px');")

2/28/2008 5:24:30 PM

There is no way to open a web page server-side. The best that you can do is render the page, or handle an event, calling the client-side function.


2/28/2008 8:20:40 PM

It is not possible server-side to physically open the page. But it is possible to register a startup script using ClientScript.RegisterStartupScript that will call and launch the new window after your click event. 

2/28/2008 10:00:55 PM


try the below one....

protected void btn_click(.......)


//   You code for update...



Software Engineer.
2/29/2008 5:33:10 AM

Similar Artilces:

Open new window from code behind
Right now, I have a new window being opened from a button event and javascript on the client side.... Button event... Page.RegisterStartupScript("startTest", "<script language='javascript'>getTest()</script>"); Client side javascript....  <script language="JavaScript">  function getTest(){ openTest=open("t1.aspx","","height=700,width=850,resizable=yes");}  </script> The thing is, I now do NOT want the javascript to be seen on the client side, but on the code behind page.  The user should not be able to know the url ...

How do I open a new Browser Window from the code behind.
If I need to open a new browser window from an aspx I would run: <asp:HyperLink id="hyperlink1" ImageUrl="images/pict.jpg" NavigateUrl="" Text="Microsoft Official Site" Target="_blank" runat="server"/> Where target="_blank" render the content in a new window. How can I do it using code behind (vb) (i.e. from xxx.aspx.vb)? Tx Job You can't do it directly, but you c...

open .aspx into new window from code-behind
hi, is there a way to direct a .aspx page to open into a new window from code executed within code-behind ??? Server.Transfer and Response.Redirect do not do the trick... perhaps Server.Execute ? any help would be much appreciated, thanx. you can use RegisterClientScriptBlock to add a short chunk of client-side javascript to open the pop-up when the main window refreshes. But you can't do what you describe directly....

open a popup window code behind
Hi I am trying to open a new window from a button in my aspx side. This works, but I have to push the button 2 times before it open. Any idea? Public Shared Sub OpenPopUp(ByVal opener As System.Web.UI.WebControls.WebControl, ByVal PagePath As String) Dim clientScript As String 'Building the client script- clientScript = "'" & PagePath & "')" 'register the script to the clientside click event of the opener control opener.Attributes.Add("onClick", clientScript) End Sub Sub Button1_Click(sender As...

VB.NET Code to open a new window
Hello,I want a new page to open up, call downloadfile, the close the page again.  how do I do that? I have a timer1_Tick going on, once a file exists, it will open a new page, call the download, and close again. On the parent page open a new window using javascript  Call the below function on the link <a href = '#' onclick = "popUp()" >DownLoadFile</a>var Popup;function popUp() { Popup ="DownLoad.aspx", "Popup", 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=420,height=300,le...

open new window from code behind, having problem
I want to open new window from a button click here is my code why wont it work? I dont get errors just no new window  Protected Sub btngo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btngo.ClickClientScript.RegisterStartupScript(Me.[GetType], "popup", ",'_blank','menubar=no')", True)   End Sub I'm not terribly familiar with the nuances of RegisterStartupScript. So, I have an alternate solution for you.ASPX<script language="javascript">    f...

Open page in a new window from Code-Behind
Is there a way to make a regular button open a page in a new window the same way you can with a hyperlink from a code behind file? I was building a JavaScript string in the CB and then doing a Response.Write but there were was an issue. I was forced to to write a period to the original page before the JavaScript Response.Write would fire, which would push my page down just a bit and I thought it was sloppy. In the interim I wrote something else but it takes the user away from the main page and that is not the optimum solution. hello, check my article here at my weblog customize it to be us...

open .aspx into new window from code-behind
hi, is there a way to direct a .aspx page to open into a new window from code executed within code-behind ??? Server.Transfer and Response.Redirect do not do the trick... perhaps Server.Execute ? any help would be much appreciated, thanx. ...

Open new window with javascript from code behind file
What do I have to change to get the line in comment working ?Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click   Page.Validate()   If (Page.IsValid) Then      If Textbox1.Text <> "" Then         UpdateButton_Click(Button1, e)      Else         InsertButton_Click(Button1, e)      End If      'Response...

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: Response.Redirect("documents/Employee.pdf"); 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? Thanks! 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, att...

opening new window from code behind using javascript
Hello,I am trying to open new window when i click on a button using javascript Page.ClientScript.RegisterStartupScript(this.GetType(), "openwindow", "'WebForm2.aspx','','height=200,width=300');", true);this is the code i am using.But the problem is it postsback whole page.Can some body tell me how i can open new window without posting back the page.ThanksVinod   Hi Vinod,Do you use a scriptmanager on your page?If so, then you should use the RegisterStartupScript method of the ScriptManager class (= ScriptManager.RegisterStar...

UpdatePanel & Opening a new window when returning from code-behind
Hi there,Here's the OnClick event code for a button inside an UpdatePanel:protected void btnReport_Click(object sender, EventArgs e){this.ClientScript.RegisterStartupScript(this.GetType(), "viewRepo", "<script>'RepoViewer.aspx','viewReport')</script>");}As you can see, after returning from code-behind I want to open a new browser window with a given web form. Well, this works correctly without an UpdatePanel, or when EnablePartialRendering is set to false. If EnablePartialRendering is set to true, a new window does not open.Any workarounds?-Benton I'm having the sam...

I am using a client side javascript to open a new window and have a problem
I have a user control..On it i have the word 'open' as a link....calling my javascript to open another page.....This page then auto close with javascript...Problem is when you click on 'open' it brings up my page and another page do you avoid this???? hello, u would like to check my article on the following address: Pop Up Window from inside ASP.NET best of luck.Bilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP...

open a new mail windows inside server side code.
Hi everybody! this is my problem, i have a Button that when i click it fire the even on the server side, making a lot of validation, and then i need to open a new email windows (outlook). It's seems easy but i really don't know how. I can use mailto because i need to make the validations in the database. Thanks in advance. why dont you just do all your validation servers side then do Response.Redirect(; perhaps that will work but i have never tested it. hth mcm i just tested it.  while it does "techincally" work you may in ...

Web resources about - Opening a new window from the code behind -

2010 Winter Olympics opening ceremony - Wikipedia, the free encyclopedia
Canadian fiddlers perform during the Opening Ceremony of the XXI Olympic Winter Games, Feb. 12, 2010, at BC Place stadium in Vancouver. The Opening ...

Facebook Testing Opening Of Links By Android App?
Facebook appears to be using the latest beta version of its Android application to quietly test allowing the app to open links, ...

Into Film Festival opening Q&A
Today I met Malala. She was giving, utterly graceful, compelling and intelligent. That might sound obvious but I was struck by this even more ...

Just a fortnight after fifth Beijing location, 28th Chinese Apple Store opening on Saturday
... Company , Apple Store , and china . What do you think? Discuss "Just a fortnight after fifth Beijing location, 28th Chinese Apple Store opening ...

Timber Timbre (solo) opening for Patrick Watson this weekend; Merganzer made a video, streaming album ...
by Andrew Sacher Merganzer (photo by Alex Brüel-Flagstad) Montreal chamber pop artist Patrick Watson is on tour now in support of this year's ...

BLS: Jobs Openings "little changed" in October
From the BLS: Job Openings and Labor Turnover Summary The number of job openings was little changed at 5.4 million on the last business day ...

1,600+ Job Openings At Tesla Motors
Originally published on EV Obsession. There are currently more than 1,600 job openings listed on Tesla’s website at the moment — including everything ...

Study: Opening Federal Lands To Drilling Worth $663 Billion Annually
Opening federal lands would also lead to $5.1 trillion in new wages and $3.9 trillion in new federal tax revenue

Quentin Tarantino’s ‘The Hateful Eight’ Moves Wide Opening To New Year’s Day
EXCLUSIVE : Seizing an opportunity to take advantage of New Year holiday business, Quentin Tarantino ’s The Hateful Eight will move up by a week ...

Resources last updated: 12/13/2015 4:57:24 PM