?
Solved

Open JavaScript window from C#.NET

Posted on 2008-10-11
1
Medium Priority
?
654 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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

649 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