List Info

Thread: Re: How to pass and capture data from a pop up or modal window in the parent




Re: How to pass and capture data from a pop up or modal window in the parent
country flaguser name
United States
2007-06-07 12:10:47

Hi Abdulla,

our code realyy makes sense but I don't know what i am doing wrong but I am not able to assign the selected value from the popup to an asp server control , however I am able to save it in an html hidden control. I have added both controls to show you how they act differently.

here is my code.

//This is the code in Pop up page page(Opener page) where the opening works fine.

<script type=";text/javascript";>


function RetrieveDialogArguments()
{

window.opener.document.getElementById(&quot;Hdnf1dhtml").value = document.getElementById("DropDownList1").value;
alert(&quot;The value is of the HTML hidden is: " + window.opener.document.getElementById(&quot;Hdnf1dhtml").value);

window.opener.document.getElementById(&quot;HdnfldASP").value = document.getElementById("DropDownList1").value;
alert(&quot;The value is of the ASP hidden is: " + window.opener.document.getElementById(&quot;HdnfldASP").value);
window.close();

}

</script>
<asp:Button ID="Button1"; runat=&quot;server&quot; Text=";Close"; OnClientClick='javascript:RetrieveDialogArguments();' />
Below is the code in the main page (Opener page) which is under a master page( I don’t know if this will make a difference.)
<script language=&quot;javascript" type=";text/javascript";>



function myopen() {
popupWindow=open('OptionList.aspx','window','resizable=no,width=400,height=300');
if (popupWindow.opener == null) popupWindow.opener = self;

}

function RefreshPage()
{

var varhtm = document.getElementById("Hdnf1dhtml&quot; ).value;


}

</script>
<input type=";text" size=";40" name=";Hdnf1dhtml" />
<asp:HiddenField ID="HdnfldASP&quot; runat=&quot;server&quot; />
<tr><td ><asp:Button ID="btnAdd" runat=&quot;server&quot; CssClass=&quot;button" Text=";Add Question&quot; OnClick=&quot;btnAdd_Click"; OnClientClick= 'javascript:RefreshPage();'/&gt;</td&gt;

My first Question is :

In the Poup under the RetrieveDialog javascript code :
The alert with the Html control alerts me the selected value from the dropdown but the alert for the asp control does not get the dropdown value at all. Why ????

Second Question:
If the asp server control does not work I was trying to use the htmlhidden however i am not sure how I would read the data in my code behine.
Using the RefreshPage function which is a javascript on the main window I can read the varthm, however how would I be able to capture this value in a code behind under the btn_Add click event. Or how can I read the Hdnf1dhtml value in my code behind as I need to save this value in my database.

Thanks a lot
Tegest

Abdulla Abd Al Haq < abdulla_ah2001%40yahoo.com">abdulla_ah2001yahoo.com> wrote:

Hi
at the first, you can pass values from popUp window to parent window using any server controls ( hiddenField, Textbox ...etc).
if you are using modalDialog, you can use (window.returnValue) to pass any value from the modal dialog just like that
//Using Modal Dialog
1- (parent page)
var x ;
x = showModalDialog('page1.aspx',window,'dialogHieght:250px;dialogWidth:366px');
2-(in ModalDialog page)
var myObj = dialogArguments;
//Now you got myObj object so you can do what you want in the parent window
window.returnvalue = document.getElementbyID("youControl&quot;).value

//Using PopuWindow
1- (parent page)
open the popWin
2-
window.opener.document.getElementById("hiddenField1&quot;).value = document.getElementById("control";).value;

as I said you can use server control
I hope its help

egest Tesfaye < tegestmelu%40yahoo.com">tegestmeluyahoo.com> wrote:
Hello,

I am having a problem capturing data on a buttob click of a parent window which is passed from a pop up window.

Here is what I am doing.

I open a popup window which has a asp dropdown list and a button. On the button ClientClik I call a javascript which asssigns the value of the dropdown selected on the popup to an HTML hidden field on the parent window as a way of capturing the selected data from the popup window in the parent widow . If I use an asp hidden field on the parent form, assigning the value from the popup to the hidden field doesn't work using the Javascript but it works if I use an html hidden field. Is there a better way to do it ? If I were able to assign the value to an asp hidden serever control it would have been easy to retrieve the data from this control anywhere in the code behind of the parent form.

So how would I be able to retrieve this value of the HTML hidden field when the asp button co on the parent form is clicked. And I am not sure how to do it. At what event of the parent page would I be able to capture the selected value on the poup and how. ? Right now I need to save this value in a database when a button on the parent window is clicked.

I am sure this is a common thing that needs to be done so if anyone of you could write me how to handle this issue I will appreciate it. If you have any question I can post the pieces of my code.

Thanks
T

---------------------------------
You snooze, you lose. Get messages ASAP with AutoCheck
in the all-new Yahoo! Mail Beta.

[Non-text portions of this message have been removed]

---------------------------------
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.

[Non-text portions of this message have been removed]

---------------------------------
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: How to pass and capture data from a pop up or modal window in the parent
country flaguser name
United States
2007-06-07 12:23:47

Tegest:
Change the following line:

<input type=";text" size=";40" name=";Hdnf1dhtml" />

to

&lt;input type=";text" size=";40" name=";Hdnf1dhtml" runat=&quot;server&quot; />

Then, you should be able to access it in codebehind like so:

Hdnf1dhtml.value

--
Brett.Stinson%40gmail.com">Brett.Stinsongmail.com

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
Re: How to pass and capture data from a pop up or modal window in the parent
country flaguser name
United States
2007-06-07 14:32:50

are you using master page ?? if you are so be sure of all clientID for all controls in the page
within master pages because master pages contain content placeholder so if you have a textbox called (txt1) in a page under master page and the content placeholder called(plc1) it will be change in the redering to ( plc1_txt1 ) so my freind my adivce is to run your page and then view source the page and take a look to your controls what happend to them after rederning there IDs will be changed



Tegest Tesfaye < tegestmelu%40yahoo.com">tegestmeluyahoo.com> wrote:
Hi Abdulla,

our code realyy makes sense but I don't know what i am doing wrong but I am not able to assign the selected value from the popup to an asp server control , however I am able to save it in an html hidden control. I have added both controls to show you how they act differently.

here is my code.

//This is the code in Pop up page page(Opener page) where the opening works fine.

<script type=";text/javascript";>

function RetrieveDialogArguments()
{

window.opener.document.getElementById("Hdnf1dhtml";).value = document.getElementById("DropDownList1").value;
alert("The value is of the HTML hidden is: " + window.opener.document.getElementById(&quot;Hdnf1dhtml").value);

window.opener.document.getElementById("HdnfldASP").value = document.getElementById("DropDownList1").value;
alert("The value is of the ASP hidden is: " + window.opener.document.getElementById(&quot;HdnfldASP").value);
window.close();

}

</script>
<asp:Button ID="Button1"; runat=&quot;server&quot; Text=";Close"; OnClientClick='javascript:RetrieveDialogArguments();' />
Below is the code in the main page (Opener page) which is under a master page( I don’t know if this will make a difference.)
<script language=&quot;javascript" type=";text/javascript";>

function myopen() {
popupWindow=open('OptionList.aspx','window','resizable=no,width=400,height=300');
if (popupWindow.opener == null) popupWindow.opener = self;

}

function RefreshPage()
{

var varhtm = document.getElementById("Hdnf1dhtml&quot; ).value;

}

</script>
<input type=";text" size=";40" name=";Hdnf1dhtml" />
&lt;asp:HiddenField ID="HdnfldASP&quot; runat=&quot;server&quot; />
&lt;tr><;td ><asp:Button ID="btnAdd" runat=&quot;server&quot; CssClass=&quot;button" Text=";Add Question&quot; OnClick=&quot;btnAdd_Click"; OnClientClick= 'javascript:RefreshPage();'/&gt;</td&gt;

My first Question is :

In the Poup under the RetrieveDialog javascript code :
The alert with the Html control alerts me the selected value from the dropdown but the alert for the asp control does not get the dropdown value at all. Why ????

Second Question:
If the asp server control does not work I was trying to use the htmlhidden however i am not sure how I would read the data in my code behine.
Using the RefreshPage function which is a javascript on the main window I can read the varthm, however how would I be able to capture this value in a code behind under the btn_Add click event. Or how can I read the Hdnf1dhtml value in my code behind as I need to save this value in my database.

Thanks a lot
Tegest

Abdulla Abd Al Haq < abdulla_ah2001%40yahoo.com">abdulla_ah2001yahoo.com> wrote:

Hi
at the first, you can pass values from popUp window to parent window using any server controls ( hiddenField, Textbox ...etc).
if you are using modalDialog, you can use (window.returnValue) to pass any value from the modal dialog just like that
//Using Modal Dialog
1- (parent page)
var x ;
x = showModalDialog('page1.aspx',window,'dialogHieght:250px;dialogWidth:366px');
2-(in ModalDialog page)
var myObj = dialogArguments;
//Now you got myObj object so you can do what you want in the parent window
window.returnvalue = document.getElementbyID("youControl&quot;).value

//Using PopuWindow
1- (parent page)
open the popWin
2-
window.opener.document.getElementById("hiddenField1&quot;).value = document.getElementById("control";).value;

as I said you can use server control
I hope its help

egest Tesfaye < tegestmelu%40yahoo.com">tegestmeluyahoo.com> wrote:
Hello,

I am having a problem capturing data on a buttob click of a parent window which is passed from a pop up window.

Here is what I am doing.

I open a popup window which has a asp dropdown list and a button. On the button ClientClik I call a javascript which asssigns the value of the dropdown selected on the popup to an HTML hidden field on the parent window as a way of capturing the selected data from the popup window in the parent widow . If I use an asp hidden field on the parent form, assigning the value from the popup to the hidden field doesn't work using the Javascript but it works if I use an html hidden field. Is there a better way to do it ? If I were able to assign the value to an asp hidden serever control it would have been easy to retrieve the data from this control anywhere in the code behind of the parent form.

So how would I be able to retrieve this value of the HTML hidden field when the asp button co on the parent form is clicked. And I am not sure how to do it. At what event of the parent page would I be able to capture the selected value on the poup and how. ? Right now I need to save this value in a database when a button on the parent window is clicked.

I am sure this is a common thing that needs to be done so if anyone of you could write me how to handle this issue I will appreciate it. If you have any question I can post the pieces of my code.

Thanks
T

---------------------------------
You snooze, you lose. Get messages ASAP with AutoCheck
in the all-new Yahoo! Mail Beta.

[Non-text portions of this message have been removed]

---------------------------------
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.

[Non-text portions of this message have been removed]

---------------------------------
Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.

[Non-text portions of this message have been removed]

---------------------------------
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )