473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

HELP: Spawning Multiple Browsers Using RegisterClientScriptBlock

Hi All,
We have an ASP.NET 2.0 (C#) intranet application that needs to spawn multiple browsers using RegisterClientScriptBlock. Here's what we got so far:

// Go thru each datarow in the datatable
foreach (System.Data.DataRow drReportGroupsDetails in tableReportGroupsDetails.Rows)
{
// Get the needed values from the datatable
string reportName = (string)drReportGroupsDetails["ReportName"];
string reportPath = (string)drReportGroupsDetails["ReportPath"];

// Do other work ...

// Build the URL - NOTE: The reportName and reportPath variables are different each time thru the loop
url = "http://localhost/..." + reportName + "..." + reportPath + "...";

// Build the javascript to display the message
sScript = "<script language=\"javascript\" type=\"text/javascript\">window.open(\"" + url + "\", \"GenerateReport\", \"height=675,width=975,left=0,top=0,copyHistory=no ,directories=no,location=no,menubar=no,resizable=n o,scrollbars=no,status=no,toolbar=no\");</script>";

// Execute the script
Page.ClientScript.RegisterClientScriptBlock(this.G etType(), "GenerateReport", sScript);
}
So, we have a method that iterates through a set of rows in a datatable, builds a URL, builds the JavaScript to open a new window (using window.open), and then executes the script using Page.ClientScript.RegisterClientScriptBlock.

The problem is that only one browser is popped-up. It's for the last row in the datatable.

How can we pop-up a new browser instance for each row in the datatable?

Thanks.

Mar 14 '06 #1
2 2785
Give the script blocks unique names. It looks like the name is always GenerateReport - so it keeps overwriting the last script, and you end up with the very last one.

If you look at the documentation for RegisterClientScriptBlock it says:
A client script is uniquely identified by its key and its type. Scripts with the same key and type are considered duplicates. Only one script with a given type and key pair can be registered with the page. Attempting to register a script that is already registered does not create a duplicate of the script.

Call the IsClientScriptBlockRegistered method to determine whether a client script with a given key and type pair is already registered and avoid unnecessarily attempting to add the script.
Give the scripts unique names. For example, use an integer that you increment to create script names like GenerateReport0, GenerateReport1, etc.
"kewl" <no****@company.com> wrote in message news:et**************@tk2msftngp13.phx.gbl...
Hi All,
We have an ASP.NET 2.0 (C#) intranet application that needs to spawn multiple browsers using RegisterClientScriptBlock. Here's what we got so far:

// Go thru each datarow in the datatable
foreach (System.Data.DataRow drReportGroupsDetails in tableReportGroupsDetails.Rows)
{
// Get the needed values from the datatable
string reportName = (string)drReportGroupsDetails["ReportName"];
string reportPath = (string)drReportGroupsDetails["ReportPath"];

// Do other work ...

// Build the URL - NOTE: The reportName and reportPath variables are different each time thru the loop
url = "http://localhost/..." + reportName + "..." + reportPath + "...";

// Build the javascript to display the message
sScript = "<script language=\"javascript\" type=\"text/javascript\">window.open(\"" + url + "\", \"GenerateReport\", \"height=675,width=975,left=0,top=0,copyHistory=no ,directories=no,location=no,menubar=no,resizable=n o,scrollbars=no,status=no,toolbar=no\");</script>";

// Execute the script
Page.ClientScript.RegisterClientScriptBlock(this.G etType(), "GenerateReport", sScript);
}
So, we have a method that iterates through a set of rows in a datatable, builds a URL, builds the JavaScript to open a new window (using window.open), and then executes the script using Page.ClientScript.RegisterClientScriptBlock.

The problem is that only one browser is popped-up. It's for the last row in the datatable.

How can we pop-up a new browser instance for each row in the datatable?

Thanks.

Mar 14 '06 #2
also for this to work, your clients will have to allow popups in their browser.

-- bruce (sqlwork.com)

"Marina Levit [MVP]" <so*****@nospam.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Give the script blocks unique names. It looks like the name is always GenerateReport - so it keeps overwriting the last script, and you end up with the very last one.

If you look at the documentation for RegisterClientScriptBlock it says:
A client script is uniquely identified by its key and its type. Scripts with the same key and type are considered duplicates. Only one script with a given type and key pair can be registered with the page. Attempting to register a script that is already registered does not create a duplicate of the script.

Call the IsClientScriptBlockRegistered method to determine whether a client script with a given key and type pair is already registered and avoid unnecessarily attempting to add the script.
Give the scripts unique names. For example, use an integer that you increment to create script names like GenerateReport0, GenerateReport1, etc.
"kewl" <no****@company.com> wrote in message news:et**************@tk2msftngp13.phx.gbl...
Hi All,
We have an ASP.NET 2.0 (C#) intranet application that needs to spawn multiple browsers using RegisterClientScriptBlock. Here's what we got so far:

// Go thru each datarow in the datatable
foreach (System.Data.DataRow drReportGroupsDetails in tableReportGroupsDetails.Rows)
{
// Get the needed values from the datatable
string reportName = (string)drReportGroupsDetails["ReportName"];
string reportPath = (string)drReportGroupsDetails["ReportPath"];

// Do other work ...

// Build the URL - NOTE: The reportName and reportPath variables are different each time thru the loop
url = "http://localhost/..." + reportName + "..." + reportPath + "...";

// Build the javascript to display the message
sScript = "<script language=\"javascript\" type=\"text/javascript\">window.open(\"" + url + "\", \"GenerateReport\", \"height=675,width=975,left=0,top=0,copyHistory=no ,directories=no,location=no,menubar=no,resizable=n o,scrollbars=no,status=no,toolbar=no\");</script>";

// Execute the script
Page.ClientScript.RegisterClientScriptBlock(this.G etType(), "GenerateReport", sScript);
}
So, we have a method that iterates through a set of rows in a datatable, builds a URL, builds the JavaScript to open a new window (using window.open), and then executes the script using Page.ClientScript.RegisterClientScriptBlock.

The problem is that only one browser is popped-up. It's for the last row in the datatable.

How can we pop-up a new browser instance for each row in the datatable?

Thanks.

Mar 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Rolf Wester | last post by:
Hi, I have a form with a select element with multiple="true". When using the GET method (I suppose the same happens with the POST method) I can seen that the form sends channels=CH1&channels=CH2...
9
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with...
0
by: ST Wong | last post by:
Hi all, I'm new to MySQL. I installed 4.0.16 on an old RedHat (7.1). Everything is okay except that 10 of mysqld daemons are started instead of 1. I checked start up options but can't find the...
29
by: Paul | last post by:
Hi, I'd like to limit the number of selections a user can make in a multiple select listbox. I have a note on the interface to say that only x no. of items should be selected and I check the...
2
by: Margaret Werdermann | last post by:
Hi all: I'm having a nasty time with a particularly difficult piece of code and was hoping someone might be able to help me. I have a FormMail form that originally worked perfectly. Then, I...
2
by: Dave Kirby | last post by:
I am working on a network management program written in python that has multiple threads (typically 20+) spawning subprocesses which are used to communicate with other systems on the network. This...
2
by: Steve K | last post by:
I got a bit of a problem I like some help on. I'm designing an online training module for people that work in food processing plants. This is my target audience. These workers have little or no...
1
by: dnes | last post by:
Open Multiple New Browser Windows from ASP.NET I'm having trouble figuring out how to open multiple new browser windows (each one displaying something different). As you can see from the code...
3
by: Andy B | last post by:
I am creating a CSS layout and need to test it with different browsers. I have the framework for the layout done with contrasting colors for each section. Can anybody if possible, go to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.