With ASP.NET 2.0
I want to add a nice and sleek feature to my application where the user
typical clicks a button to open a smaller window to enable a search, lets
say for customers or products or whatever.
So far this is easy by adding a script tag and window.open with appropriate
settings.
The challenge comes when the user has searched and selected his item, and
clicks [Ok] in this popup form.
How do I return the values to the calling form, into the appropriate
textboxes?
If this cannot be done directly on the client side, I think this may be done
with a postback of the caller form, but then; how do I force a callback of
the first form (the caller form) when the secondary (the pop-up) closes?
(And yes, I know the search issue can be solved with hiding/showing panels
or views on an asp-form, but I would like to simulate a more windows like
behaviour, if possible)
Bjorn
Teemu Keiski - 30 Jun 2007 13:01 GMT
Hello,
maybe my blog post helps you
ASP.NET: How to create a postback on a main page from a popup window
http://aspadvice.com/blogs/joteke/archive/2005/06/15/2340.aspx
Basically you can just set them with script, but you can also do it via
postback. Per my sample, it's totally up to how the script on the main page
is generated.

Signature
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
> With ASP.NET 2.0
>
[quoted text clipped - 20 lines]
>
> Bjorn
Bjorn Sagbakken - 30 Jun 2007 16:47 GMT
Thanks. I have saved your blog to my favorites and will try it out later.
It explains a lot, so I think it will be very useful.
Bjorn
> Hello,
>
[quoted text clipped - 31 lines]
>>
>> Bjorn
Masudur - 30 Jun 2007 13:03 GMT
> With ASP.NET 2.0
>
[quoted text clipped - 19 lines]
>
> Bjorn
Hi Bjorn
well you can access your parent pages elements using javascript...
here is a little code that will help you understand...
if(window.opener!=null)
{
window.opener.document.getElementById('Text1').value =
document.getElementById('Text2').value;
}
this is a script used in child page to set a value to a text box in
the parent page...
the trick is window.opener object of a page...
but i would like to suggest different technique...
why don't you user a javascript dhtml layer div popup and then use
javascript to hide and show the search box..
and also take advantage of Ajax to get the search result...
http://ajax.asp.net/ajaxtoolkit/ have few beautiful modal popup
demonstration
Thanks
Munna
www.kaz.com.bd
http://munnacs.110mb.com
Bjorn Sagbakken - 30 Jun 2007 16:34 GMT
>> With ASP.NET 2.0
>>
[quoted text clipped - 46 lines]
> http://ajax.asp.net/ajaxtoolkit/ have few beautiful modal popup
> demonstration
Thanks a lot. I tried your first suggestion, and it worked like a dream.
But I will also pursue the Ajax solution, it is just a bit more to get into.
But it seems like a good idea for the future.
Just one small silly question at the end: How do I close the pop-up window
with code? Would this be server code or client code?
(there has never been any need to close any form before, only rediirect...)
Bjorn