Blog Stats
  • Posts - 62
  • Articles - 1
  • Comments - 41
  • Trackbacks - 64

 

Popup Windows in ASP.NET

In order to recreate the UI experience found in an existing Access forms Db I was porting to ASP.NET, I really wanted to use popup forms when the user clicked on a list of available items. Each item was unique and I would dynamically load an user control into a placeholder on teh child form based on what item criteria was passed to it (in a query string). On the parent form, the list of items would toggle between either "Edit" Or "Add" depending on whether the container object for the items already had that item in it or not persisted to the Db. So I built a nifty server control that would popup my new window and send the encrypted query string ot the child page. The child would parse the querystring and then dynamically load the appropriate ascx in my manager class. Poof! Worked great! So now the hard part. I wanted to be able to save the data in the child form and then update the parent form;s toggled "Edit/Add" button text, indicating a new item had been persisted. Simply causing a postback on the child form's unload event wouldn't work because the parent form would actually post BEFORE the child form and then bind its controls prior to my child page's save event. I needed to be able to process the data fetched from the child page FIRST on the server and THEN cause the update inthe parent form. What to do? I implemented a bool variable "postbackParent" which would be set to "true" when my child page's Save event occured. Then, I hooked into the page's PreRender event from the ascx and checked if postbackParent was true. If it is, I emit a bit of javascript onto the child page's "load" event that fires the postback on the parent page. WAHLAH! The page updates with the binding using the new data from teh child form.

Feedback

# re: Popup Windows in ASP.NET

Gravatar Hi,
this exactly what I want to do but I am having some problems. if you could help me please?

parent window - when user click on a button, I open a window.showModalDialog

the child window open just fine. in it load event, I grab the query strings (a bunch of ids) then connect to sl to get the data. then when the user click on SAVE on the child window, I need to grab the value of all the controls (txtbox, dropdown, ...) and save to the sql and then close the page.

since I had to write a java script to close the window, I can never get the event to work to execute the SAVE method before closing. it just closes. any ideas?

thanks,
9/1/2006 11:46 AM | farsh

# re: Popup Windows in ASP.NET

Gravatar Farsh,
I think the problem you are having is due to using a modal dialog box. Since I needed cross-browser support (not just ie) I avoided this.
The issue for me was that the server-side methods need to run and then refresh the parent page after doing so.
I built a web control that might do what you are looking for. send me your email address and I can forward it to you.
check out these <a href="http://www.utmag.com/wconnect/wc.dll?9,7,10,680">resources</a> as well.


MIKE 9/1/2006 12:04 PM | Mike

# re: Popup Windows in ASP.NET c

Gravatar ew2dfffffffffffffffffffffffffffffffff 7/5/2007 2:41 AM | sdsd

# re: Popup Windows in ASP.NET

Gravatar I have a listbox which displays all the usernames...if i click a name a popup has to open.....wil anybody help!!! 8/14/2007 5:37 AM | lucky

# re: Popup Windows in ASP.NET

Gravatar Find Your Answers at www.ebookserver .org 5/1/2008 2:12 AM | davindersingh

# re: Popup Windows in ASP.NET

Gravatar Hiii,
Here is the solution..
http://ramcrishna.blogspot.com/2008/09/working-with-popups-in-aspnet.html 9/10/2008 6:29 AM | Ramky

Post a comment





 

Please add 3 and 6 and type the answer here:

 

 

Copyright © Mike Nichols