[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Inform webpage that popup has closed

Posted on 2012-03-29
10
Medium Priority
?
524 Views
Last Modified: 2012-03-29
I have a textbox on a webpage whose click event opens a calendar popup.

What do I need to do so that the main webpage 'knows' that the popup calendar has been closed?

My overall goal is to:
    1.  Open the popup calendar when the user clicks the texbox
    2.  Return and display the selected date in the textbox on the main page
    3.  Run some code on the main page immediately upon closing the popup

I have 1 and 2 worked out, but am stuck on 3.

(I'm using VB.Net/ C# /Visual Studio 2008)

Please let me know if more info is needed.

Thanks (!)
0
Comment
Question by:mbizup
[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
  • 6
  • 3
10 Comments
 
LVL 61

Author Comment

by:mbizup
ID: 37782176
I have tried using the TextChanged event of the textbox that accepts the date from the popup calendar, but that event does not seem to get triggered by the popup writing the date to the textbox on the main page.
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 2000 total points
ID: 37782622
the popup should be able to fire a function in the parent with:

parent.yourfunction();
self.close();


Cd&
0
 
LVL 61

Author Comment

by:mbizup
ID: 37782784
That makes sense - it sounds like I have been approaching this from the wrong direction.

Does my syntax look okay?

<asp:Button ID="Button1" runat="server" onclick="parent.foo(); self.close();" Text="Button" />

I'm getting a compilation error saying that I'm missing a close parenthesis, but I don't see where.


That is in the markup for my popup calendar.  Am I putting the code in the right place?
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 61

Author Comment

by:mbizup
ID: 37782827
Okay - here's a really stupid question.  

My function "Foo()" is currently in the VB.Net code behind the parent form as a public function.  Will it work like that, or do I have to write it in Javascript and put it in the markup?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37782902
Are you using AJAX Calendar Extender control?  Use its OnClientHidden property

http://www.dotnetfunda.com/articles/article1001-ajax-calendarextender.aspx

http://forums.asp.net/p/1335624/2690286.aspx
0
 
LVL 61

Author Comment

by:mbizup
ID: 37782962
Hi CC,

This is the example I was following for the calendar, using the built in VS.Net calendar:

http://www.codeguru.com/csharp/csharp/cs_date_time/article.php/c19401/Creating-a-Popup-Date-Picker.htm

I'll take a look at sites that you posted, too.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 37783009
As soon as we drift off into asp and vb it leaves me behind.  I'm an open source developer.  However to answer the question, about javascript, yes the recommendation I posted asumes the function is written in javascript in the parent page.


Cd&
0
 
LVL 61

Author Comment

by:mbizup
ID: 37783409
Cd&,

That was completely brilliant!

My original approach (trying to determine when the popup closed) was backwards.

Using javascript to call a javascript function worked beautifully, when I got rid of the asp tags - which from your last comment, I think needed to be done.

This is what I wound up with:
    // This is in the popup - 
    function fooPopup()
    {
        window.opener.fooParent();
        self.close();
    }
    <button id="Button1" onclick="fooPopup();"></button>


        // This is in the main form - 
        function fooParent() {
            alert("Hello");
            document.getElementById('TextBox1').value = "Aloha";
            // This clicks an asp button --
            document.getElementById('Button1').click();
        }

Open in new window


What is very, very cool - and what I was ultimately trying to get at - is that you can use that to click a command button to run VB.Net or C# functions.

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Response.Write("This Works!!")
    End Sub

Open in new window


I'm just so happy, I could click that button all day!!
0
 
LVL 61

Author Closing Comment

by:mbizup
ID: 37783412
Thanks!
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 37783506
The original concept behind the site was an Expert in something helping an Expert in something else.  A true exchange between Experts.

Glad to help.  :^)


Cd&
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

650 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