Showing posts with label parent. Show all posts
Showing posts with label parent. Show all posts

Thursday, March 29, 2012

Passing values between 2 open pages (eg. parent and dialog)

Can someone tell me if there is another way of passing variables back and forth between 2 open pages (such as in the case of a dialog window) without using javascript.

I have done it before using javascript but now that I am using a lot of user controls on my pages I find it a pain in the butt with how the user controls are being named, especially when you have multiple nested controls.

Any help would be greatly appreciated.
Thanks.You could use session variables, but this would require that each of the pages involved do a postback in order to be able to read the session variables. Otherwise, javascript is your best bet.
Alright, thanks mendhak, just thought I would check to see if there was a better way.

Passing values from a child window

hi all,
I have a parent window default.aspx which has a textbox(txtBox1) with
multiline property and a button.when the button is clicked a child
window pops up child.aspx.
I have four textboxes in child.aspx and a submit button.What I want to
happen is when I click the submit button all the values must be
displayed in the multiline textbox in a table format with header and
the values below or any formatted display with headers.
I am using,
window.opener.documents.forms[0].txtBox1.value method to pass the
values.
can anybody help me to fix the values from the child window to the
parent window in a formatted display.I have been trying this for a day.
thanksHello ssrivani@.gmail.com,
From what I understood, after opening the child window and filling in the ch
ild form, you want to be able to:
1- Format the form field values in an html table.
2- copy the resulting html to the opening window and have it inserted into t
he multi line text field.
Try the attached files and see if it works for you.

> hi all,
>
> I have a parent window default.aspx which has a textbox(txtBox1) with
> multiline property and a button.when the button is clicked a child
> window pops up child.aspx.
> I have four textboxes in child.aspx and a submit button.What I want to
> happen is when I click the submit button all the values must be
> displayed in the multiline textbox in a table format with header and
> the values below or any formatted display with headers.
> I am using,
> window.opener.documents.forms[0].txtBox1.value method to pass the
> values.
> can anybody help me to fix the values from the child window to the
> parent window in a formatted display.I have been trying this for a
> day.
>
> thanks
>

passing values from chil pop up to parent

Hello Everyone,
I am trying to pass the value from my child window to my parent window. I
don't get the value from child to my parent when I refresh my parent page,
if I don't refresh my parent page then I get the value frtom my child window
.
Below is the code in my parent window and child page. I need to refresh my
parent page because once the page refreshes and the child window closes, I
want some method to execute
btnSubmit.Attributes.Add("onclick", "window.open('newForm.aspx' ,
'CustomPopUp','width=600, height=400, statusbar=no, menubar=no,
resizable=no') ");
txtName.Text = hdnPopResult.Value; // assigning hidden filed value to a text
filed on asp.net page
my child window
function passvalues()
{
var txtValue = document.getElementById("txtSubmit").value;if(txtValue !="")
{
window.opener.form1.hdnPopResult.value = txtValue;
opener.document.location.reload();
window.close();
}
}
btnSubmit.Attributes.Add("onclick", "passvalues()");
Any help will be apprecaited."Vinki" <Vinki@.discussions.microsoft.com> wrote in message
news:93A10F20-93D0-438B-9BC7-C012DEBAB555@.microsoft.com...

> I am trying to pass the value from my child window to my parent window. I
> don't get the value from child to my parent when I refresh my parent
> page,
> if I don't refresh my parent page then I get the value frtom my child
> window.
That's normal behaviour - think about it...
When you tell a page to reload, that's exactly what it will do i.e. it will
load in precisely the way that it loaded previously - it won't "remember"
the fact that it has been changed client-side *after* it was last loaded...

> I need to refresh my parent page because once the page refreshes and the
> child window closes, I want some method to execute
Is this method client-side or server-side?
Mark Rae
ASP.NET MVP
http://www.markrae.net
you should submit the parent instead of reload.:
window.opener.form1.hdnPopResult.value = txtValue;
window.opener.form1.submit();
-- bruce (sqlwork.com)
Vinki wrote:
> Hello Everyone,
> I am trying to pass the value from my child window to my parent window.
I
> don't get the value from child to my parent when I refresh my parent page
,
> if I don't refresh my parent page then I get the value frtom my child wind
ow.
> Below is the code in my parent window and child page. I need to refresh my
> parent page because once the page refreshes and the child window closes, I
> want some method to execute
> btnSubmit.Attributes.Add("onclick", "window.open('newForm.aspx' ,
> 'CustomPopUp','width=600, height=400, statusbar=no, menubar=no,
> resizable=no') ");
> txtName.Text = hdnPopResult.Value; // assigning hidden filed value to a te
xt
> filed on asp.net page
> my child window
> function passvalues()
> {
> var txtValue = document.getElementById("txtSubmit").value;if(txtValue !=""
)
> {
> window.opener.form1.hdnPopResult.value = txtValue;
> opener.document.location.reload();
> window.close();
>
> }
>
>
> }
> btnSubmit.Attributes.Add("onclick", "passvalues()");
> Any help will be apprecaited.
>
>
It is a server side code.
"Mark Rae [MVP]" wrote:

> "Vinki" <Vinki@.discussions.microsoft.com> wrote in message
> news:93A10F20-93D0-438B-9BC7-C012DEBAB555@.microsoft.com...
>
> That's normal behaviour - think about it...
> When you tell a page to reload, that's exactly what it will do i.e. it wil
l
> load in precisely the way that it loaded previously - it won't "remember"
> the fact that it has been changed client-side *after* it was last loaded..
.
>
> Is this method client-side or server-side?
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
>
"Vinki" <Vinki@.discussions.microsoft.com> wrote in message
news:EA7EA873-2502-48F0-A12A-A826F6854E4A@.microsoft.com...

> It is a server side code.
Bruce has already given you the correct answer...
Mark Rae
ASP.NET MVP
http://www.markrae.net

Monday, March 26, 2012

Passing values to a pop-up window and de-activating parent window...

Hello All,

How are you guys doing today? Hope all is well.

This is my scenario...

What I want to be able to do is 3 things...first, when I click a hyperlink, I would like to display another aspx page in a pop-up window...second, I need to pass values from the parent window to the child (pop-up) and third...I also would like to deactivate the parent window when the child window is visible! Any guidelines as to how I can accomplish all of this is highly appreciated.

Thanks,

Mohammed

This sounds like something you can do with theASP.NET AJAX Modal Popup window.


You can do this using javascript as well. using window.showModalDialog() and dialogArguments. Here is link to an example:

http://www.java2s.com/Code/JavaScriptReference/Javascript-Methods/showModalDialogExample.htm


Thank you very much for your help Jon. I appreciate you getting back to me.


Hello Darrell,

Appreciate your feedback and thank you for your support.

passing values to showmodal dialog

I have parent.aspx web page from which I call a modal dialog (child.aspx via
showmodaldialog). I'd like to populate two text boxes, <asp:TextBox id=txt
_HN> on the child form with data from the caller.
for parent.aspx....
<script> block
function UpdH(title,horse)
{
var iParms=new Object();
iParms.Name=horse;
...}
for child.aspx...
<script> block
I've tried "document.getElementById('txt_HN').value=iParms.Horse;" within ch
ild.aspx form - but get error "document.getElementbyId(...) is null or not a
n object". How do I do this?David,
Try dialogArguments.window.document.getElementById....
using the following to open your window in java script:
var TestWindow = new Object();
TestWindow.caller = window.showModalDialog(URLstr, window, sFeatures);
replacing the parameters there with whatever you use as appropriate.
Raymond Lewallen
"DavidS" <DavidS@.discussions.microsoft.com> wrote in message
news:564EE97A-8C7D-4E35-B034-99BB78A95904@.microsoft.com...
> I have parent.aspx web page from which I call a modal dialog (child.aspx
via showmodaldialog). I'd like to populate two text boxes, <asp:TextBox
id=txt_HN> on the child form with data from the caller.
> for parent.aspx....
> <script> block
> function UpdH(title,horse)
> {
> var iParms=new Object();
> iParms.Name=horse;
> ...}
> for child.aspx...
> <script> block
> I've tried "document.getElementById('txt_HN').value=iParms.Horse;" within
child.aspx form - but get error "document.getElementbyId(...) is null or not
an object". How do I do this?

passing values to showmodal dialog

I have parent.aspx web page from which I call a modal dialog (child.aspx via showmodaldialog). I'd like to populate two text boxes, <asp:TextBox id=txt_HN> on the child form with data from the caller.
for parent.aspx....
<script> block
function UpdH(title,horse)
{
var iParms=new Object();
iParms.Name=horse;
...}
for child.aspx...
<script> block
I've tried "document.getElementById('txt_HN').value=iParms.Hor se;" within child.aspx form - but get error "document.getElementbyId(...) is null or not an object". How do I do this?David,

Try dialogArguments.window.document.getElementById... .

using the following to open your window in javascript:

var TestWindow = new Object();
TestWindow.caller = window.showModalDialog(URLstr, window, sFeatures);

replacing the parameters there with whatever you use as appropriate.

Raymond Lewallen

"DavidS" <DavidS@.discussions.microsoft.com> wrote in message
news:564EE97A-8C7D-4E35-B034-99BB78A95904@.microsoft.com...
> I have parent.aspx web page from which I call a modal dialog (child.aspx
via showmodaldialog). I'd like to populate two text boxes, <asp:TextBox
id=txt_HN> on the child form with data from the caller.
> for parent.aspx....
> <script> block
> function UpdH(title,horse)
> {
> var iParms=new Object();
> iParms.Name=horse;
> ...}
> for child.aspx...
> <script> block
> I've tried "document.getElementById('txt_HN').value=iParms.Hor se;" within
child.aspx form - but get error "document.getElementbyId(...) is null or not
an object". How do I do this?

passing variable from child to parent - possible ?

I have a main form, and i have another form i need to call on a button
press,
then id like the result of the child form to pass data back to the parent -
without losing any data previously entered
on the parent - is this possible ? ( my main parent window is starting to
get quite cluttered)

cheers

markmark wrote:
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark

The problem is in not losing the "parent" data... Are these windows open
in the same browser window or are you opening the "child" in a new
window? If its the same just save their existing data, in a
db/viewstate/session/etc, and then when you reload it retrieve it.
If not you will have to force the "parent" to postback to get it to
refresh, and with the viewstate enabled you should get the pre-entered
data to remain

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Mark,

The standard way is to call javascript method showModalDialog for the child
form. The child form can pass back data in javascript window.returnValue
property which the parent form will get as a return value of the
showModalDialog call.

Eliyahu

"mark" <mark@.remove.com> wrote in message
news:1122386021.4716.0@.spandrell.news.uk.clara.net ...
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the
parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
Mark,

The standard way is to call javascript method showModalDialog for the child
form. The child form can pass back data in javascript window.returnValue
property which the parent form will get as a return value of the
showModalDialog call.

Eliyahu

"mark" <mark@.remove.com> wrote in message
news:1122386021.4716.0@.spandrell.news.uk.clara.net ...
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the
parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
> The problem is in not losing the "parent" data... Are these windows open
> in the same browser window or are you opening the "child" in a new
> window? If its the same just save their existing data, in a
> db/viewstate/session/etc, and then when you reload it retrieve it.
> If not you will have to force the "parent" to postback to get it to
> refresh, and with the viewstate enabled you should get the pre-entered
> data to remain
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com

looks like ill be forced to save on opening the child, either that i
redesign the whole form to be more modular
problem is - i have to pass an ID to the child that doesnt exist until the
parent is saved - so things are getting more complicated
than in reality they should be

cheers

mark
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OvYQHtekFHA.1464@.TK2MSFTNGP14.phx.gbl...
> Mark,
> The standard way is to call javascript method showModalDialog for the
child
> form. The child form can pass back data in javascript window.returnValue
> property which the parent form will get as a return value of the
> showModalDialog call.
> Eliyahu
got any examples ?

thanks

mark
> The problem is in not losing the "parent" data... Are these windows open
> in the same browser window or are you opening the "child" in a new
> window? If its the same just save their existing data, in a
> db/viewstate/session/etc, and then when you reload it retrieve it.
> If not you will have to force the "parent" to postback to get it to
> refresh, and with the viewstate enabled you should get the pre-entered
> data to remain
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com

looks like ill be forced to save on opening the child, either that i
redesign the whole form to be more modular
problem is - i have to pass an ID to the child that doesnt exist until the
parent is saved - so things are getting more complicated
than in reality they should be

cheers

mark
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OvYQHtekFHA.1464@.TK2MSFTNGP14.phx.gbl...
> Mark,
> The standard way is to call javascript method showModalDialog for the
child
> form. The child form can pass back data in javascript window.returnValue
> property which the parent form will get as a return value of the
> showModalDialog call.
> Eliyahu
got any examples ?

thanks

mark

passing variable from child to parent - possible ?

I have a main form, and i have another form i need to call on a button
press,
then id like the result of the child form to pass data back to the parent -
without losing any data previously entered
on the parent - is this possible ? ( my main parent window is starting to
get quite cluttered)

cheers

markmark wrote:
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark

The problem is in not losing the "parent" data... Are these windows open
in the same browser window or are you opening the "child" in a new
window? If its the same just save their existing data, in a
db/viewstate/session/etc, and then when you reload it retrieve it.
If not you will have to force the "parent" to postback to get it to
refresh, and with the viewstate enabled you should get the pre-entered
data to remain

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

passing variable from child to parent - possible ?

I have a main form, and i have another form i need to call on a button
press,
then id like the result of the child form to pass data back to the parent -
without losing any data previously entered
on the parent - is this possible ? ( my main parent window is starting to
get quite cluttered)
cheers
markmark wrote:
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the parent
-
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
>
The problem is in not losing the "parent" data... Are these windows open
in the same browser window or are you opening the "child" in a new
window? If its the same just save their existing data, in a
db/viewstate/session/etc, and then when you reload it retrieve it.
If not you will have to force the "parent" to postback to get it to
refresh, and with the viewstate enabled you should get the pre-entered
data to remain
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
Mark,
The standard way is to call javascript method showModalDialog for the child
form. The child form can pass back data in javascript window.returnValue
property which the parent form will get as a return value of the
showModalDialog call.
Eliyahu
"mark" <mark@.remove.com> wrote in message
news:1122386021.4716.0@.spandrell.news.uk.clara.net...
> I have a main form, and i have another form i need to call on a button
> press,
> then id like the result of the child form to pass data back to the
parent -
> without losing any data previously entered
> on the parent - is this possible ? ( my main parent window is starting to
> get quite cluttered)
> cheers
> mark
>
> >
> The problem is in not losing the "parent" data... Are these windows open
> in the same browser window or are you opening the "child" in a new
> window? If its the same just save their existing data, in a
> db/viewstate/session/etc, and then when you reload it retrieve it.
> If not you will have to force the "parent" to postback to get it to
> refresh, and with the viewstate enabled you should get the pre-entered
> data to remain
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com
looks like ill be forced to save on opening the child, either that i
redesign the whole form to be more modular
problem is - i have to pass an ID to the child that doesnt exist until the
parent is saved - so things are getting more complicated
than in reality they should be
cheers
mark
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OvYQHtekFHA.1464@.TK2MSFTNGP14.phx.gbl...
> Mark,
> The standard way is to call javascript method showModalDialog for the
child
> form. The child form can pass back data in javascript window.returnValue
> property which the parent form will get as a return value of the
> showModalDialog call.
> Eliyahu
>
got any examples ?
thanks
mark

Passing Variable to UserControl From Parent Page

Hi All, I would like to know how to pass a variable to a user control.

An example would be _menu.ascx, which is a user control and is used in every aspx page such as default.aspx. It's properly set using the @dotnet.itags.org.Register tag in the html pages.

CODEBEHIND FOR DEFAULT.ASPX.CS
--------------
public class _default : System.Web.UI.Page
{
````public string strVariable; // want to use this variable in usercontrol

````private void Page_Load(object sender, System.EventArgs e)
````{
````````strVariable = "Hello World";
````}
}

CODEBEHIND FOR _MENU.ASCX.CS
--------------
public abstract class __menu : System.Web.UI.UserControl
{
````protected System.Web.UI.WebControls.Repeater repMenu;

````private void Page_Load(object sender, System.EventArgs e)
````{
````````DataAccess hdlData = new DataAccess();
````````repMenu.DataSource = hdlData.getMenu(??????); // stuck here!!
````````repMenu.DataBind();
````}
}use a Session["name"] object

psi
Is there another way of passing it, instead of using a Session["name"] variable? My variable is actually in the base class (business class), which all the aspx pages inherit from

CODEBEHIND FOR BUSINESS CLASS PAGEHELPER.CS
--------------------
public class PageHelper : System.Web.UI.Page
{
````public string strVariable; // want to use this variable in usercontrol

````public PageHelper()
````{
````````strVariable = "Hello World";
````}
}

CODEBEHIND FOR DEFAULT.ASPX.CS
--------------
public class _default : PageHelper
{
````private void Page_Load(object sender, System.EventArgs e)
````{
````````// this page inherits the PageHelper.cs class, which
````````// sets all the necessary variables.
````}
}

CODEBEHIND FOR _MENU.ASCX.CS
--------------
public abstract class __menu : System.Web.UI.UserControl
{
````protected System.Web.UI.WebControls.Repeater repMenu;

````private void Page_Load(object sender, System.EventArgs e)
````{
````````DataAccess hdlData = new DataAccess();
````````// this needs to get variable in PageHelper.cs class
````````repMenu.DataSource = hdlData.getMenu(??????); // stuck here!!
````````repMenu.DataBind();
````}
}
yes, you should be able to do this, and assess it from the user control:

PageHelper class is public
public string strVariable;

add this property ...
public string StrVariable
{
get{return var;}
set{var = value;}
}

you would then have to instatiate an instance of PageHelper and call the Property:
PageHelper ph = new PageHelper();

//get variable ...
ph.StrVariable

hope that helped
psi
Thank you for all the help psinyc!!!

It works now =)
good