Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have a HTML Pages in Dir HTMLReports... I want to open HTML pages on user Click in New Window. I have taken one Button and on click of that button Update Pannel Triggers a PostBack... An on button click event I have written this Code..

VB
httpContext.Current.response.Write("<Script> window.open('HtmlReports/HtmlRpt.html','Rpt_Title') </Script>")
httpContext.Current.response.end()


My output is Something Like this...

A New Window Get Open Along With HtmlRpt.html is Displayed
but
My Current Page In Which i Have Button That Becomes Blank Nothing is Displayed

How to overcome this problem? Please give me some suggestions
Posted
Updated 6-May-12 23:13pm
v2

C#
<a href="Enter ur address here" target="_blank">Enter</a>


When you have select the 'Enter', you will be redirect to the targeted page in new window.
 
Share this answer
 
Do not use server side code to open the window into new pop-up location (if its not required). You can use the client side functionality to open the window in new pop-up location. The code is:

<a href="The Address You want to be open" target="_blank"> The Label to be display </a>

Let me know if you need more information.
 
Share this answer
 
Use this CP article
Response.Redirect into a new window[^]
 
Share this answer
 
The problem is the update panel is replacing whatever is in it with the script, removing what is there. I haven't tested this, but the following should work:

Markup
ASP.NET
<asp:UpdatePanel id="Whatever" runat="server">
    <!-- ...Your existing controls here -->
    <asp:Literal id="Whatever" runat="server" visible="false" 
   text="<Script>window.open('HtmlReports/HtmlRpt.html','_blank')</Script>" />
</asp:UpdatePanel>

Now, on the click event, just set the Visible propert of the Literal to true and it will render the existing controls and the script.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900