views:

359

answers:

3

I am using asp.net webforms 2.0, c#.

What I need is a simple, elegant way to do the following:

User clicks an element in webform A; Webform B pops up; User interracts with webform B; On closing webform B, probably by a submit button, the source element in webform a a is updated with a value from webform B.

What technologies would be involved here? Aside from Javascript and c#, of course. Can I do it without Ajax?

EDITED:

To clarify, WEBform B will save the data entered into the database, say customer information, then it will come back with the customer ID (after saving), this customer ID needs to be passed to the parent window, which should refresh after this.

+1  A: 

Hi

You can use JavaScript:

<script language="javascript">
window.opener.location.reload();
self.close();
</script>

The above code shows how to close the 'opener' window, but it should give you the general idea. (This code is in the Popup window). You can use the same method to pass values to the 'opener' window by calling JavaScript function within it.

<script language="javascript">
window.opener.functionA('ABC123');    
</script>

If you want to pass a variable from your ASP into the JavaScript function, use:

window.opener.functionA('<%=userId%>');

or

var userId = '<%=userId%>';
window.opener.functionA( userId );

Hope that helps!

uuɐɯǝʃǝs
Thanks. I should have clarified myself, see my edits.
gnomixa
A: 
Matt
+1  A: 

If you are using ASP.NET 2.0, you can have the second page post back to the first and then detect it with IsCrossPagePostBack.

JP Alioto
thanks will consider it.
gnomixa