PDA

View Full Version : [CLOSED] Parameters or variables sent from parent page



JCarlosF
Feb 07, 2013, 4:46 PM
I need to use parameters or variables in child page, these parameters are sent from a parent page, for example:

this is my application, the home page (parent page) is composed of a viewport with a TabPanel in the center and on the left menu:

5572

By clicking on any of the menu options, for example I click on "Contracts", shows the following:

5573

shows the catalog of contracts (child page), it and each of the menu items are aspx files

I want to click on the contracts or any other, send a parameter that can be used in the codebehind of contratos.aspx (child page)

I hope to be clear in my problem and I hope you can help me,
thanks!

geoffrey.mcgill
Feb 07, 2013, 8:46 PM
If you're loading the inner page into an iframe, how about send the extra information as a parameter of the Url?

JCarlosF
Feb 07, 2013, 9:59 PM
maybe I did not explain well,

in the codebehind of page contratos.aspx, I need to use a variable that contains an identifier of the option contratos.aspx, that identifier or parameter is extracted from the database,

I will use this parameter to validate permissions on contratos.aspx.

Permissions to modify, to add new record, to delete a record, etc.

Baidaly
Feb 07, 2013, 11:20 PM
maybe I did not explain well,

in the codebehind of page contratos.aspx, I need to use a variable that contains an identifier of the option contratos.aspx, that identifier or parameter is extracted from the database,

I will use this parameter to validate permissions on contratos.aspx.

Permissions to modify, to add new record, to delete a record, etc.

Hello!

I don't quite understand you.

You have a Parent Page which has some parameter and you want to use this parameter on CodeBehind side of second page when it opens? If I'm right please try the following approach:

ParentPage.aspx


<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Window win = new Window()
{
ID = "Window1",
Title = "Child Page",
Width = Unit.Pixel(400),
Height = Unit.Pixel(200),
Modal = true,
AutoRender = false,
Collapsible = true,
Maximizable = true,
Hidden = true,
Loader = new ComponentLoader
{
Url = "~/ChildPage.aspx",
Mode = LoadMode.Frame,
LoadMask =
{
ShowMask = true
}
}
};

// Here you can put any value
win.Loader.Params.Add(new Ext.Net.Parameter("myparam", "Parameter from parent page", ParameterMode.Value));

this.Form.Controls.Add(win);
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET Examples</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Show Window" Icon="Application">
<Listeners>
<Click Handler="#{Window1}.show(this);" />
</Listeners>
</ext:Button>
</form>
</body>
</html>



ChildPage.aspx



<%@ Page Language="C#" EnableViewState="true" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
ParamField.Text = Request.Params["myparam"];
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Portlet drop test</title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:TextField runat="server" FieldLabel="Received Parameter" ID="ParamField" Width="300"></ext:TextField>
</body>
</html>

JCarlosF
Feb 08, 2013, 7:35 PM
Thanks, this solved my problem very well

VirtualArtists
Sep 14, 2013, 9:38 AM
hi - Regarding this Thread: The Solution above seems good if you only need to pass in a single parameter.

Could you expand on this, and recommend a solution for passing more complex data to the child form?
For example:

Question: How would you suggest to pass a "HashTable" from parent page, into the child page?

Daniil
Sep 16, 2013, 5:24 AM
Hi @VirtualArtists,

According to the fact that a request can transmit strings only. A HastTable should be serialized on the parent page and deserialized on the child page. It looks the only solution if you need to send that parameter through a request. Another solution could storing the parameter somewhere on the server, for example in the Application global object.

ada
Sep 16, 2013, 7:35 AM
Hello!

I don't quite understand you.

You have a Parent Page which has some parameter and you want to use this parameter on CodeBehind side of second page when it opens? If I'm right please try the following approach:

ParentPage.aspx


<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Window win = new Window()
{
ID = "Window1",
Title = "Child Page",
Width = Unit.Pixel(400),
Height = Unit.Pixel(200),
Modal = true,
AutoRender = false,
Collapsible = true,
Maximizable = true,
Hidden = true,
Loader = new ComponentLoader
{
Url = "~/ChildPage.aspx",
Mode = LoadMode.Frame,
LoadMask =
{
ShowMask = true
}
}
};

// Here you can put any value
win.Loader.Params.Add(new Ext.Net.Parameter("myparam", "Parameter from parent page", ParameterMode.Value));

this.Form.Controls.Add(win);
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET Examples</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Show Window" Icon="Application">
<Listeners>
<Click Handler="#{Window1}.show(this);" />
</Listeners>
</ext:Button>
</form>
</body>
</html>



ChildPage.aspx



<%@ Page Language="C#" EnableViewState="true" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
ParamField.Text = Request.Params["myparam"];
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Portlet drop test</title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:TextField runat="server" FieldLabel="Received Parameter" ID="ParamField" Width="300"></ext:TextField>
</body>
</html>


I just wondering so thats why I aske it ,what if he want to do this,(I mean adding tab and pass the parameters,) via usercontroler ascx,what would u advise.thank u

Daniil
Sep 16, 2013, 11:17 AM
I just wondering so thats why I aske it ,what if he want to do this,(I mean adding tab and pass the parameters,) via usercontroler ascx,what would u advise.thank u

I think it is a candidate for a new forum thread. Please start. If you feel the threads are related, please feel free to cross-link between the two.