Solved

Open JavaScript window from C#.NET

Posted on 2008-10-11
1
649 Views
Last Modified: 2013-12-17
This function opens the page in a new window... I would like to control window size, location, toolbars, etc... I want the window to only have the address bar, nothing else...
protected void rHotels_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandArgument != null)
        {
            StringBuilder openWindow = new StringBuilder();
            openWindow.Append("<script>open('");
            openWindow.Append("HotelDetail.aspx?HotelID=" + e.CommandArgument);
            openWindow.Append("');</script>");
            Page.RegisterStartupScript("OpenWindows", openWindow.ToString());
 
 
 
        }
    }

Open in new window

0
Comment
Question by:conrad2010
1 Comment
 
LVL 8

Accepted Solution

by:
rlh68 earned 500 total points
ID: 22695154

The below code will do what you want, notice the forth line has changed. Additionally, it sizes and positions the window too. Remove the height, width, top, and left if you don't want to size and/or position the new window.

StringBuilder openWindow = new StringBuilder();
openWindow.Append("<script>open('");
openWindow.Append("HotelDetail.aspx?HotelID=" + e.CommandArgument);         openWindow.Append("','WindowTitle','width=500,height=500,left=50,top=50,toolbar=0,resizable=0,location=0,status=0,menubar=0,scrollbars=0');</script>");
Page.RegisterStartupScript("OpenWindows", openWindow.ToString());


To learn more...
http://msdn.microsoft.com/en-us/library/ms536651(VS.85).aspx

http://www.javascripter.net/faq/openinga.htm
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question