Solved

Open JavaScript window from C#.NET

Posted on 2008-10-11
1
646 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now