Click here to Skip to main content
16,018,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written this code, but my problem it is opened in the same window.
Response.Redirect("TankerPositionPreview.aspx?Preview=" + value, True)

I would like to open it in new window.

Thanks
Posted
Updated 11-Nov-11 22:28pm
v2

Response.Redirect is only going to work within the existing window. Instead, you need to write out some javascript to open the new window as

XML
<%function openlink(link)%>
<SCRIPT language='javascript'>window.open(' <%=strLocation%> ');</SCRIPT>
<%end function%>
 
Share this answer
 
Comments
RaviRanjanKr 12-Nov-11 14:12pm    
My 5+
if you want to open it in new window use the javascript
in following example i have open new window on submit click

write a javascript function

JavaScript
<script type="text/javascript">
function open_wind()
{
    window.open("TankerPositionPreview.aspx")
   return false;
}
</script>


call this function on onclientclick

ASP.NET
<asp:button id="btnOne" runat="server" value="submit" onclientclick="return open_wind()" xmlns:asp="#unknown"></asp:button>
 
Share this answer
 
Comments
ujjwal uniyal 12-Nov-11 5:13am    
not working
you can take simple html button like this...

<input type="button" id="buttest"  runat="server" value="open" />



then go to cs file add below code into load event that will open new window and page will redirect to the another page with the query string value.

buttest.Attributes.Add("onclick", "window.open('TankerPositionPreview.aspx?Preview=" + value + "')");
 
Share this answer
 
v2
Comments
RaviRanjanKr 12-Nov-11 14:13pm    
Always wrap your code in "pre" tag.
Response.Redirect does not open in a new window. The second parameter to Response.Redirect doesnot say the compiler to open it in a new window. it only says whether to execute the remaining code in the current page before redirecting to the target page.
 
Share this answer
 
v2
Comments
RaviRanjanKr 12-Nov-11 14:15pm    
[Edited]Minor Formating[/Edited]
Use this code
C#
Responce.Redirect="Select the page url"
 
Share this answer
 
Comments
DINESH K MAURYA 12-Nov-11 4:22am    
but it not open in new window
Response.Redirect("~/PageName.aspx");
 
Share this answer
 
v2
Comments
RaviRanjanKr 12-Nov-11 14:16pm    
A suggestion :- Always use "pre" tag or Code block to wrapped your Codes. it gives better readability to other user.

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