473,748 Members | 10,771 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="Chi ldWin.aspx.vb"
Inherits="PTTim esheet.ChildWin "%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>ChildWin </title>
<meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<pt:styleShee ts xmlns:pt="http://www.plumtree.co m/xmlschemas/ptui/" />
<script language="javas cript">
function doInit()
{
var intPayrollPerio dID;
var strContactID;
var intTimesheetID;

var parentArgs = new
Array(intPayrol lPeriodID,strCo ntactID,intTime sheetID);
parentArgs = window.dialogAr guments;

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

alert("Recievin g: " + intPayrollPerio dID + "|" + strContactID + "|" +
intTimesheetID) ;

window.execScri pt("__doPostBac k('BindDataGrid ','" + parentArgs +
"')","JavaScrip t");
}
</script>
</HEAD>
<body onLoad="doInit( );">
<form id="PTTimesheet _Detail" method="post" runat="server">
<asp:Label id="lblPayrollP eriodID" runat="server"> </asp:Label>
<asp:Label id="lblContactI D" runat="server"> </asp:Label>
<asp:Label id="lblTimeshee tID" runat="server"> </asp:Label>
</form>
</body>
</HTML>

Paul
Nov 19 '05 #1
1 4994
Paul,

Include a javascript function in your calling page like this:

<script language=javasc ript>
function opendialog(dlgl ocation, querystring, dlgheight, dlgwidth,
dlgtop, dlgleft){
var
dialogposition= 'width='+dlgwid th+',height='+d lgheight+',top= '+dlgtop+',left ='+dlgleft;
if (querystring!=n ull){
dialoglocation+ ='?'+querystrin g;
}
var NewWindow = window.open(dia loglocation,'di alog',dialogpos ition);
if (NewWindow.focu s!=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.RegisterCl ientScript. 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:hyperlin k runat=server id="lnkopenchil dwindow" navigateurl=<%#
"javascript:ope ndialog('dialog s/dlgcomplainants .aspx','paramet er1=" &
tbparameter1.te xt & "&parameter 2=" &
tbparameter2.te xt',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.EventArg s) Handles MyBase.Load
If Not Page.IsPostBack Then
'Get parameters from the query string if they exist
If Request.QuerySt ring("parameter 1") <> "" Then
tb1.Text = Request.QuerySt ring("parameter 1")
End If

If Request.QuerySt ring("parameter 2") <> "" Then
tb2.Text = Request.QuerySt ring("parameter 2")
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
4345
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) { window1=open("solution.php?folder=folder1&file=file1"); }
3
4669
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 the criterias in a querystring to the new window. but if it's possible i don't want to use query string. in asp, i could use the folowing: i open a temporary blank window, on load I take the values of the search
6
7094
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 with the related description. This is done and is obviously not a concern. However, now I would like to make it so the corresponding row becomes highlighted (changes background colour via DOM). I imagine it can be done, but I'm at a loss for...
29
5024
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 window properly but does not pass the parameter. (this is part of a coldfusion template) <a href="##"
19
3879
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 ReuseParameterValuesOnRefresh="True" in a viewer, but it still doesn't work. Did anyone run into this problem. What's the solution? Please help. Thank you
3
4066
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 textbox then clicks the button and on page load the child window should grab that val run a query an present the results. Given that I am bouncing between server side controls and client script. I am just having a little trouble passing my textbox...
3
3454
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 am wanting to then use this value within an element of a form on the current page -
5
2424
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 variables value needs to be passed from the main page to this popup window ... but it isn't. why? the submit button one the PHP page is
12
37870
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 three input fields in parent window and three in popup window parent.htm
3
7714
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" OnClientClick="openwindow()" Text="Execute"/> <script type="text/javascript"> function openwindow() { window.open("AssignedTickets.aspx",'window','width=630,height=620,background=silver,menubar=no, resizable=no') }
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.