Solved

Modal Popup selecting setting drop list on parent form

Posted on 2014-11-03
7
197 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

688 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