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

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


.
 
A

alex bowers

hi cheryl,
The dialog form is opened by the parent window from
javascript (eg window.showModalDialog
('ModalWindow.aspx',this,'[etc,etc]')). Note the use
of 'this' as the second argument in the function; this
allows you to refer back to the parent window from the
dialog form's javascript.
Now when you want to refer back to the parent window
(which is when you pass arguments back to the parent from
the dialog form - eg the form data) you need to write
some CLIENT-SCRIPT such as
window.dialogArguments.ProcessModalData
([form data args])
this will call a function in the parent window called
ProcessModalData.
From the error message you received, it sounds as though
you may have been calling this function using server-side
code. You can only do this on the client (or write
server-side code that writes script out to the client -
but you'll need to research this a little if you haven't
done it before).
The next step is to process the data on the main page
somehow, and there a few different techniques I've used
to do this. The simplest is to store the data in a
hidden-text field on the client, then process it using
server side code later. You can also force the page to
post-back to itself from the client-side script, then
process the data on the server. Look into calling the
__doPostBack('control','') client-function for info on
this.

alex
-----Original Message-----
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
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


.



.
 
A

alex bowers

There's another simpler way of doing this - a child form
can change the url of it's parent window using the
following script function:
opener.location='something.aspx?argument1=x&argument2=y'
This will force the parent page to refresh itself on the
server, and process the querystring arguments accordingly
(which are the values determined in the child window).
This will work with a child window that is opened using
window.open(), however I'm not sure if this will work
with a modal dialog.
alex
-----Original Message-----
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
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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top