Creating a browser window

  • Thread starter Thread starter David W. Simmonds
  • Start date Start date
D

David W. Simmonds

Is there an easy way to create a new browser window from C# and ASP.NET? I
would just like to have a popup window without any menus or toolbars that
would contain a high-res image. The low-res image would be in the main
window and would have a button that when pressed brings up the "popup"
window that has the high-res image. I would like the window to be re-used
instead of creating yet another popup window if the user navigates to
another low-res image and then hits the button again.
 
I know nothing about java, although I could figure it out. If you have an
example of what you mean it would save me a lot of time.
 
I added code like this to the Page_Load method:

StringBuilder scriptb = new StringBuilder();
scriptb.Append("<script language=\"javascript\">\n" +
"function NewImageWindow(url)\n" +
"{\n" +

"\twindow.open(url,\"Image\",\"toolbar=no,location=no,directories=no,menubar
=no,resizable=no,scrollbars=yes,width=400,height=320\");\n" +
"}\n" +
"/script>\n");
if(!Page.IsClientScriptBlockRegistered("clientNewImageWindowScript"))
Page.RegisterClientScriptBlock("clientNewImageWindowScript",
scriptb.ToString());

Now I need to add a hyperlink or a button that calls NewImageWindow with a
url in it. How might that be accomplished?
 
I added the following code to complete the task:

private void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
PlaceHolder plLinks = (PlaceHolder)e.Item.FindControl("plLinks");
plLinks.Controls.Add(new LiteralControl(String.Format(
"<A href=\"javascript:NewImageWindow('{0}');\">Click for
high-res image</A>&nbsp;&nbsp;",

"ImageProcessor.aspx?filename="+photos.Tables[0].Rows[nRow]["ImageUrl"].ToSt
ring()+"&width=-1" )));
}
}

The datalist1 control has a PlaceHolder control in the Header Template named
plLinks. When the item is clicked, it calls the NewImageWindow.

Is there a way to change the caption of the window that is created?
 
Hi Dave

I have something like this where I have a Hyperlink control on the web page and in the code-behind I set its NavigateUrl property like the following. I'm poping up the GenLookup.aspx page but You can probably replace that with a .JPG file name

' set up the hyperlink to start the generic looku
HyperLink1.NavigateUrl = "javascript:mywindow=window.open(""GenLookup.aspx"",""mywindow"",""height=700,width=1000,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes"");mywindow.focus();

If the name 'mywindow' is the same for all links then each will use the same window

Hope that helps
Joh
 
This is a way better way than I was doing it. Thanks. I am calling an ASPX
page too.

Do you know of a way to change the caption of the popup window?

John said:
Hi Dave,

I have something like this where I have a Hyperlink control on the web
page and in the code-behind I set its NavigateUrl property like the
following. I'm poping up the GenLookup.aspx page but You can probably
replace that with a .JPG file name.
 
Well, when I run my pop-up the caption says something lik

GenLokup - Microsoft Internet Explore

The first part is the <title> GenLookup </title> html title in my aspx screen. I'm sure that is a property you can change to Visual Studio or directy in the html code view of you web form. I can't figure out how to get rid of the 'Microsoft Internet Explorer' bit

I looked at the window.open properties and did not see anything there that lets you set the title

John
 
Hmm, it seems that mine does now too. Could have been a cache issue.

Whatever, it seems to work now.

Thanks a bunch for the assistance.

John said:
Well, when I run my pop-up the caption says something like

GenLokup - Microsoft Internet Explorer

The first part is the <title> GenLookup </title> html title in my aspx
screen. I'm sure that is a property you can change to Visual Studio or
directy in the html code view of you web form. I can't figure out how to
get rid of the 'Microsoft Internet Explorer' bit.
 
Back
Top