open window a new window and retrieve data from it. C#

C

Cheryl

Hi,

I have encounter a problem.Language use is C#. I would like to open a new
window (is a modal window, where I m not able to switch from parent window
after this window is open)from the parent window , where there are 3
dropdownlists and a "OK" button. Upon clicking the button, this window
will close and the select of the dropdownlists will be collect and send back
to the parent window. But I am do not know how to do it. Can somebody help.

Thanks
Cheryl
 
A

alex bowers

Hi Cheryl,
you can achieve this by opening a model window through
some javascript in the main page, then calling a function
in the original page from the new window when the ok
button is clicked that processes the data from the modal
window.
The original page can process the modal form data using
javascript with the example below, but you can extend
this to process the data server side by forcing a
postback.

alex

Here's a code example:

[Modal Window - ModalWindow.aspx] [C#]
function ModalButtonClick()
{
if( window.dialogArguments )
window.dialogArguments.ProcessModalData
(dropdown1.value,dropdown2.value,dropdown3.value);
window.close();
}

<SELECT id='dropdown1'>
//additional dropdownlists rendered here
<INPUT type=button onclick='ModalButtonClick();'
value='submit'>

[main page] [C#]
function ShowModalWindow()
{
window.showModalDialog
('ModalWindow.aspx',this,'dialogWidth:400px;dialogHeight:2
00px;center;help:no;Yes;resizable:yes;status:no;scroll:no'
);

}

function ProcessModalData(string1,string2,string3)
{
//javascript to do something with the form data
passed in here
}
 
C

Cheryl

Hi alex,

I am new in both javascript and asp.net. After putting in the code, I
have encountered this error msg, "Object doesn't support this property or
method"
on "window.dialogArguments.ProcessModalData
(dropdown1.value,dropdown2.value,dropdown3.value);" . And does not know what
when wrong.

And I got another problem, after the form data have passed back to the main
page. How am I going to get the data and place it on the datagrid.


Thanks
Cheryl
alex bowers said:
Hi Cheryl,
you can achieve this by opening a model window through
some javascript in the main page, then calling a function
in the original page from the new window when the ok
button is clicked that processes the data from the modal
window.
The original page can process the modal form data using
javascript with the example below, but you can extend
this to process the data server side by forcing a
postback.

alex

Here's a code example:

[Modal Window - ModalWindow.aspx] [C#]
function ModalButtonClick()
{
if( window.dialogArguments )
window.dialogArguments.ProcessModalData
(dropdown1.value,dropdown2.value,dropdown3.value);
window.close();
}

<SELECT id='dropdown1'>
//additional dropdownlists rendered here
<INPUT type=button onclick='ModalButtonClick();'
value='submit'>

[main page] [C#]
function ShowModalWindow()
{
window.showModalDialog
('ModalWindow.aspx',this,'dialogWidth:400px;dialogHeight:2
00px;center;help:no;Yes;resizable:yes;status:no;scroll:no'
);

}

function ProcessModalData(string1,string2,string3)
{
//javascript to do something with the form data
passed in here
}
-----Original Message-----
Hi,

I have encounter a problem.Language use is C#. I would like to open a new
window (is a modal window, where I m not able to switch from parent window
after this window is open)from the parent window , where there are 3
dropdownlists and a "OK" button. Upon clicking the button, this window
will close and the select of the dropdownlists will be collect and send back
to the parent window. But I am do not know how to do it. Can somebody help.

Thanks
Cheryl


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top