?
Solved

Open JavaScript window from C#.NET

Posted on 2008-10-11
1
Medium Priority
?
653 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
rlh68 earned 2000 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

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

770 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