?
Solved

Modal Popup selecting setting drop list on parent form

Posted on 2014-11-03
7
Medium Priority
?
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
7 Comments
 
LVL 20

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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

764 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