Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Passing parameters to a Popup Window and getting them in Code-Behind

Reply
Thread Tools

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

 
 
Paul D. Fox
Guest
Posts: n/a
 
      05-11-2005
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 xmlnst="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


 
Reply With Quote
 
 
 
 
billmiami2@netscape.net
Guest
Posts: n/a
 
      05-11-2005
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=<%#
"javascriptpendialog('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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing parameters to an executable vs. passing them to a server Ramon F Herrera C++ 8 09-13-2009 02:48 AM
javascript popup window and multiple parameters DaveyP ASP .Net 1 07-24-2007 10:51 AM
passing post parameters having space in them ramata ASP General 1 05-06-2005 05:17 PM
New Popup Window from an existing Popup Window Raffi Javascript 4 08-12-2004 01:21 PM
Main > Popup > Popup > Close popup AND new URL in main? Jens Peter Hansen Javascript 7 06-19-2004 08:56 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57