473,508 Members | 2,206 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing parameters to a Popup Window and getting them in Code-Behind

I'm trying to launch a Child Window from a hyperlink on a Datagrid and have
it recieve multiple values from the Parent Window. Upon recieving the
values in the Child Window, I need to access them in the code-behind so I
can render a datagrid in the Child. I've tried just doing another Postback
in the child's onLoad event but I get a Javascript error. Is there another
way to do this?

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ChildWin.aspx.vb"
Inherits="PTTimesheet.ChildWin"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>ChildWin</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<pt:styleSheets xmlns:pt="http://www.plumtree.com/xmlschemas/ptui/" />
<script language="javascript">
function doInit()
{
var intPayrollPeriodID;
var strContactID;
var intTimesheetID;

var parentArgs = new
Array(intPayrollPeriodID,strContactID,intTimesheet ID);
parentArgs = window.dialogArguments;

intPayrollPeriodID = parentArgs[0].toString();
strContactID = parentArgs[1].toString();
intTimesheetID = parentArgs[2].toString();

alert("Recieving: " + intPayrollPeriodID + "|" + strContactID + "|" +
intTimesheetID);

window.execScript("__doPostBack('BindDataGrid','" + parentArgs +
"')","JavaScript");
}
</script>
</HEAD>
<body onLoad="doInit();">
<form id="PTTimesheet_Detail" method="post" runat="server">
<asp:Label id="lblPayrollPeriodID" runat="server"></asp:Label>
<asp:Label id="lblContactID" runat="server"></asp:Label>
<asp:Label id="lblTimesheetID" runat="server"></asp:Label>
</form>
</body>
</HTML>

Paul
Nov 19 '05 #1
1 4961
Paul,

Include a javascript function in your calling page like this:

<script language=javascript>
function opendialog(dlglocation, querystring, dlgheight, dlgwidth,
dlgtop, dlgleft){
var
dialogposition='width='+dlgwidth+',height='+dlghei ght+',top='+dlgtop+',left='+dlgleft;
if (querystring!=null){
dialoglocation+='?'+querystring;
}
var NewWindow = window.open(dialoglocation,'dialog',dialogposition );
if (NewWindow.focus!=null){
NewWindow.focus();
}
}
</script>

Where

dlglocation is the URL of the child window you would like to open
querystring is a querystring containing parameters you would like to
pass to the child
dlgheight, dlgwidth, dlgtop, dlgleft are the height, width, distance
from top and distance from left of the child window, respectively.

Normally, I place functions like this in a VB (or C#) component and add
them to the page as necessary with Page.RegisterClientScript. In this
way, you have a central repository of javascript functions.
From a link on your calling page, call the opendialog function above

grabbing parameter values on the way:

<asp:hyperlink runat=server id="lnkopenchildwindow" navigateurl=<%#
"javascript:opendialog('dialogs/dlgcomplainants.aspx','parameter1=" &
tbparameter1.text & "&parameter2=" &
tbparameter2.text',400,410,.5*(screen.height-400),.5*(screen.width-410));"
%>

In the code behind for the child, pick up the parameters from the
querystring and do something with them

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
'Get parameters from the query string if they exist
If Request.QueryString("parameter1") <> "" Then
tb1.Text = Request.QueryString("parameter1")
End If

If Request.QueryString("parameter2") <> "" Then
tb2.Text = Request.QueryString("parameter2")
End If

End If
End Sub

I hope this helps you.

Bill E.
Hollywood, FL

Nov 19 '05 #2

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

Similar topics

3
4330
by: Raju V.K | last post by:
can I use javascript and PHP in the following manner to create a pop-up window: <--- in <head> </head> <script language=javascript> function popup(folder1, file1) {...
3
4662
by: Joe Abou Jaoude | last post by:
hi, I have a search page im asp.net. the user enter the criterias in textboxes and dropdownlists and on submit i want the results to be displayed in a popup window. so the easy way is to pass...
6
7066
by: veganeater | last post by:
Hi Everyone, I was wondering if there was a way to pass a variable to a popup window. The purpose is make it so when a user clicks on a specific region/link of the glossary page, a popup opens...
29
4959
by: wayne | last post by:
Hey there... I'm having some problems passing url parameters with an open.window command. I'm not terribly familiar with java script but here is the code below. When executed it opens the...
19
3847
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
3
4052
by: Aaron | last post by:
I am having a little difficulty with a relatively simple task. I have a parent webform. I have a javascript attribute added to a button to open a new window when clicked. The user fills in a...
3
3426
by: michael | last post by:
let me keep it clean, quick and simple. I am passing a variable into another window and am reassigning the value on the new page - window.document...value = opener.document. ....value and...
5
2405
by: Steve | last post by:
Hi, I currently have a problem passing a variable value from one page to another. Once a form submit button is pressed java pops up a window and displays some information. The problem being is...
12
37769
meenakshia
by: meenakshia | last post by:
hi forum i have read a lot of articles regarding passing data from popup to parent up but i m looking for the opposite that is from parent to popup window pls help me in this regard i have...
3
7700
by: pavanip | last post by:
Hi, I have written the code for display popup window using javascript in button onclient click event. <asp:Button ID="Button1" runat="server" Style="position: static"...
0
7225
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
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7383
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...
1
7046
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
5627
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
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.