Solved

Modal Popup selecting setting drop list on parent form

Posted on 2014-11-03
7
177 Views
Last Modified: 2014-11-28
I have an asp.net form with a selection list on it that contains many items.  I want a modal popup to provide search criteria to narrow the selection, and once the selection is made, to set the ddlb on the parent form (and close the modal popup).  I am having trouble getting this to work.  When I choose the item in my modal popup, I call a method on the parent form to select the ddlb.  It doesn't work (the selection is made, but it doesn't persist).  I think I need to post back the form.  When I try and use the timer to generate a postback, the timer fires continuously, even after I disable it.

What would the proper way to code this be?
0
Comment
Question by:No1Coder
  • 4
7 Comments
 
LVL 19

Expert Comment

by:Daniel Van Der Werken
ID: 40423730
You can't really have a child call a parent in ASP .NET. It works the other way around just fine. You need to persist value you're selected. Probably your best bet is to use a session variable. Do something like this:

Session["MyVariableName"] = value_selected_by_user_in_modal_box;

Then, when the modal dialog is closed, get the value such like:

string mySelectedValue = Session["MyVariableName"].ToString();

or

int mySelectedInt = int.MinValue;
int.TryParse(Session["MyVariableName"].ToString(), out mySelectedInt); // gets the integer value.
0
 

Author Comment

by:No1Coder
ID: 40423783
Okay, but what event triggers the selection being set from the session variable?

Currently, when he hits OK on the popup, I locate the parent using something like:

parent = (ucParent)this.Parent.Parent.Parent;  

Then I call a method on parent to do some work:

parent.RefreshDropDown(valueselected)

The method gets called, and the DDLB value is selected, but it doesn't persist.  This technique I guess is not valid, but not sure why.  I have tried firing a timer event in the parent method, and setting the ddlb value on the timer event, but this has different issues.  The timer continuously fires, even after being disabled.

So, if instead I set a session variable when he hits OK, how do I trigger an event on the parent to refresh the DDLB?

Thanks for assisting.
0
 

Author Comment

by:No1Coder
ID: 40449565
Additional Information

On my modal popup, the user clicks a selection link.  This causes the selection to be made, and the modal popup to close (manually, using Hide).  When debugging (with breakpoints set), this causes a postback on parent form.  When running without breakpoints, no parent postback occurs.  Somehow, I need to reliably notify the parent form that the modal popup has closed.  Is there a recommended way to do this?
0
 

Accepted Solution

by:
No1Coder earned 0 total points
ID: 40460516
I resolved the issue.  In the popup window, i used jquery code to generate acpostback on parrent form by clicking a hidden button.
0
 

Author Closing Comment

by:No1Coder
ID: 40470196
Solution found
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now