opening multiple popup windows from code behind

HI

I am trying to open multiple pop up windows from code behind for the purpose of showing xls files but in only seems to work with one window. this is the code that I have so far. it works fine but when I'm trying to pop up more than one browser it only shows the first one. 

file_array = dir.GetFiles("*.xls")

For Each file In file_array

ClientScript.RegisterStartupScript (Me.GetType, "popup & file.Name &", "window.open('" & path & "','blank','menubar=no')", True)

Next

Can somebody help me in this matter.

Thanks in advanced.

 

 

 

 

-1
baldonieves
3/7/2008 3:54:11 PM
asp.net.client-side 24353 articles. 0 followers. Follow

3 Replies
2018 Views

Similar Articles

[PageSpeed] 16

the situation is cause by "popup & file.Name &",it's totally a constant string,and won't change during the loop,so all the script you registered will have the same KEY,so the later one will override the previous one!

 
you should change ClientScript.RegisterStartupScript (Me.GetType, "popup & file.Name &", "window.open('" & path & "','blank','menubar=no')", True)  to

ClientScript.RegisterStartupScript (Me.GetType, "popup" & file.Name, "window.open('" & path & "','blank','menubar=no')", True)
 


code for fun
----------------
Don't forget to mark it as Answer if it's useful for you
1
ycm119
3/7/2008 5:24:41 PM

okay now, this is what I came up with so each time the key would be different and this time it works only when a single file is in the directory but when theres more than one file it doesn't do anything and the main page from which these popups are called from finishes with the message at the bottom done but with errors on page.

file_array = dir.GetFiles("*.xls")

For Each file In file_array

ClientScript.RegisterStartupScript (Me.GetType, "popup" & counter.ToString, "window.open('" & app_path & file.Name & "','_blank','menubar=no')", True)

counter = counter + 1

Next

1
baldonieves
3/7/2008 6:43:44 PM

You need to have a unique second argument to the JavaScript window.open function. Try this:

ClientScript.RegisterStartupScript (Me.GetType, "popup" + counter.ToString, "window.open('" + path + "','blank' + new Date().getTime(),'menubar=no')", True)

NC...

1
NC01
3/7/2008 7:28:03 PM
Reply:

Similar Artilces:

open a popup window from.net code behind
Hi I am trying to open a new window from a button in my aspx side. This works, but I have to push the button 2 times before it open. Any idea? Public Shared Sub OpenPopUp(ByVal opener As System.Web.UI.WebControls.WebControl, ByVal PagePath As String) Dim clientScript As String 'Building the client script- window.open clientScript = "window.open('" & PagePath & "')" 'register the script to the clientside click event of the opener control opener.Attributes.Add("onClick", clientScript) End Sub Sub Button1_Click(sender As...

how to open popup window through javascript in code behind( popup window should be aligned center)
I want to use javascript in code behind to open popup window. I have Datalist inside which there is linkbutton. On click of linkbutton open popup window through javascript & that pop up window should be aligned centraly.Regards,Mahesh--------------------click "Mark as Answer" on the post that helps you. Friend, Try this sample . <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Untitled Page</title>        <style>    .blue{ bac...

Open popup window on click of button event from code behind side
 Hi friends I have one button called Preview which is placed in upadate panel. Now I want to open popup window on click of that button. I can call javascript onclientclick event but before open popup window i want to get some values from current window.I dont want to pass that value in query string. Here is my code <pre> ClientScript.RegisterStartupScript(this.GetType(), "JS", "javascript:window.open('PreviewPop.aspx?DesignID=" + txtImageHide.Value + "','MyTitle','height=250,width=505, top=100, left=100, scrollbars=yes, res...

open popup window from code behind
hi i am coding with vb , i need to open pop up window with out display any tool bars. and also need to pass a value to opening page which will need to get related data to display on pop up. need to cal java script inside a vb method   You can call this either via javascript or use Ajax Here is a good example http://www.codeproject.com/KB/custom-controls/asppopup.aspx  or the JavaScript version, which uses the the ScriptManager for the JavaScript: C#public static void OpenWindow(Page currentPage, String window, String htmlPage, Int32 width, Int32 height) { ...

Opening multiple windows from code behind
Hi, I am making a web applications, where the users can post new messages for everyone to see (in their department). Every one minute the show messages page checks for new message and needs to show popup window with some part of the new message that has been posted. I have been able to show one popup window using response.write method and writing javascript window.open code in it. Even the RegisterStartupScript method works fine. The problem is if in case there are 2 or more messages being posted in that 1 minute time, I need to show multiple popup windows. How can I do that? Thanks ...

How to open a popup window from C# code behind
Hi, When users click on submit button on my application, first it validates the data using requiredfieldvalidators, and then once all the data is perfect a popup window should open that tells them "please wait, processing request", the window stays as long as the parent unloads, I am able to do it by using Javascript and adding OnClick attribute to the button, but the problem is the popup opens everytime we click the button, even if it it fires the validators and not move to the next page, Can Anyone Help?? How about adding the popup code to the onsubmit event handler of the form tag inst...

Want to open a popup window from code behind
Hi,I want to open a Popup window with code behind in ASPX page. So if you have ant codes and suggestion please do mail me.I am online on yahoo messsanger in invisible mode and my yahoo chat is is 'naveen_uicsa'ThanxNaveen Hello, use registerstartupscript function .Dim mystr as new StringBuilderwith mystr  .append("<script language='javascript'>")  .append("window.open(theUrl, '', 'toolbar=0,width=350,height=250,left=40,top=50');")  .append("</script>")end withregisterStartupScript("PopupScript", mystr.ToString)Hope this would help.Regards,ForzaOracle, mySQL &...

How to open a popup window from C# code behind
Hi, When users click on submit button on my application, first it validates the data using requiredfieldvalidators, and then once all the data is perfect a popup window should open that tells them "please wait, processing request", the window stays as long as the parent unloads, I am able to do it by using Javascript and adding OnClick attribute to the button, but the problem is the popup opens everytime we click the button, even if it it fires the validators and not move to the next page, Can Anyone Help?? How about adding the popup code to the onsubmit event handler of the form tag inst...

Question about client side and code behind code
How is code behind code processed on client side? I ask because I'm trying to figure out a problem I have with a link button in a gridview. If I open the page and run it as normal everything fires fine. I click on the link button and it loads the new page. However if I email the page to myself and click on the link button nothing happens. I do not think that the Gridview_Rowcommand fires. The link button represents a DB ID field and all the code is in the GridView_RowCommand event in the code behind and fires a Server.Transfer at the end to load the new page. I have tried Response.Redi...

execute 'window.open' client script function in server side code
I am using button control(web control) on my page (ReportControl.aspx). On button_click I want to open another page ReportViewer.aspx (in new browser) but before that I should able to collect control values of ReportControl.aspx and pass to that new page. So that i will use them on page_load of that new page(ReportViewer.aspx). Please reply urgent. Use this:ScriptManager.RegisterStartupScript(this, typeof(string), "OpenWindowScript", "window.open('ReportViewer.aspx');", true); Thanks kipo for your reply. How i pass parameter to this page (i collect par...

Javascript confirm message in c# code behind,by clicking ok popup window open
how can i set a confirm javascript message in c# code behind and by clicking ok i have to open a pop up .aspx page. Hello,     Add onclick attribute with javascript function containing window.open() within your c# code. btn.Attributes.Add("onclick", "javascript:window.open('YourPage.aspx')")  Thanks,santosh_maharajaPlease mark as answer if you got expected solution. http://plugins.jquery.com/project/confirm  Cool stuff // The action. $('span').mouseover(function() { $(this).html('Here is the offer'); });   $(&...

How to know in the code behind if the window has been open from another window
 HiI want to know in the code behind (server side) if the page has been open from another window. In the client side I can check, in a javascript function, if the window.opener is null or not, but how can I know this in the code behind. Is it possible?Thanks,Luis Miguel   I think your best bet might be to use a HiddenField, and populate that HiddenField with the javascript window.opener value. For example: <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html P...

superreview granted: [Bug 263844] Javascript window.close() on popup not working when popup is opened in tab : [Attachment 162257] set opener on opened windows diverted into tabs
Boris Zbarsky <bzbarsky@mit.edu> has granted Boris Zbarsky <bzbarsky@mit.edu>'s request for superreview: Bug 263844: Javascript window.close() on popup not working when popup is opened in tab https://bugzilla.mozilla.org/show_bug.cgi?id=263844 Attachment 162257: set opener on opened windows diverted into tabs https://bugzilla.mozilla.org/attachment.cgi?id=162257&action=edit ------- Additional Comments from Boris Zbarsky <bzbarsky@mit.edu> r+sr=bzbarsky. Dan, thanks for doing this! I really wish we could factor some of this code that's being copied f...

Popup window appears behind opener window in v2.0
I have a web app that contains a button which brings up a popup window when clicked.  It worked just fine in ASP.NET 1.0 (using Studio 2003). But now that I converted my project over to ASP.NET 2.0 (using Studio 2005), my popup window appears, but then immediately hides behind the opener window. The only way I've found to get around this problem is to put "onload=self.focus()" in the BODY tag of the popup window - and even then, if I look closely, I can see the popup window appear, immediately go behind the opener window, and then appear again when the 'onload' got called. Here's my c...

Web resources about - opening multiple popup windows from code behind - asp.net.client-side

Code division multiple access - Wikipedia, the free encyclopedia
Code division multiple access ( CDMA ) is a channel access method used by various radio communication technologies. It should not be confused ...

Jakarta attacks: Multiple bombs hit Indonesian capital
ISIS has claimed responsibility for the grenades and crude homemade bombs used to stage a Paris-style attack in a busy business and shopping ...

Sopranos star Jamie-Lynn Sigler has Multiple Sclerosis
... daughter of mobster Tony Soprano on the Emmy-winning drama, has gone public with her struggle with her nearly 15-year battle with multiple sclerosis. ...

Jakarta attacks: seven dead in multiple attacks linked to Islamic State
Jakarta is on highest possible alert for terrorism, after multiple explosions hit Central Jakarta on Thursday.

Jakarta attacks: seven dead in multiple attacks linked to Islamic State
Seven people have been killed in a terrorist attack in central Jakarta, including five who are believed to be perpetrators linked to the Islamic ...

Feature Request: Apple TV 4 needs a way to watch TV shows from multiple sources in one universal app
... coverage of AAPL Company , Apps , and iOS . What do you think? Discuss "Feature Request: Apple TV 4 needs a way to watch TV shows from multiple ...

Google Seeks Multiple Auto Partners for Self-Driving Car Unit
Google hopes to form partnerships with many automakers and suppliers as it develops self-driving cars to reduce traffic accidents and expand ...

Here’s what happens to your eyes when you look at multiple screens
It's more common than ever for people to stare at screens on multiple devices – some at the same time. Here's a tip for what you can do to protect ...

Multiple Explosions, Gunfire Rock Jakarta In Deadly ISIS-Claimed Attack
At least seven people died, including five assailants, a police spokeperson said. Multiple explosions and a gun battle rocked Jakarta, the capital ...

Ramon Foster: Multiple Bengals Spit On Steelers, Not Just Burfict
Steelers OL Ramon Foster joins The Fan Morning Show

Resources last updated: 1/21/2016 11:11:08 PM