Solved

Make a Change on a .NET Web Form from a Popup

Posted on 2014-03-26
5
264 Views
Last Modified: 2014-06-01
I have a simple example but I look for a general principle in how to do.

I have a web form, webform1, with a lable control Lable1. From webform1 I open a popup, popup1, with e.g.

function PopupOpen()
{
    window.open('Test.aspx', '_blank', 'width=900,height=450,top=312,left=190,scrollbars=1')
}

in the script section:

<script type="text/javascript" language="javascript">

With the popup1 open and active, my question is how can I in popup1 make a change to Lable1 in webform1?
0
Comment
Question by:Kim Neesgaard
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:Ryan McCauley
ID: 40035961
I'm a bit unclear on the question, but just to be sure, are you trying to modify a value in the first form based on activity in the pop-up window? If so, I believe it's called a "cross-domain iFrame", and you can see a demo here:

http://www.codeproject.com/Tips/585663/Communication-with-Cross-Domain-IFrame-A-Cross-Bro

While not an exact demo of what you're looking for, it demonstrates communication across windows and should cover the concept you'll use to do this. If I've missed your question, please provide some additional details and I'll update my answer.
0
 

Accepted Solution

by:
Kim Neesgaard earned 0 total points
ID: 40050227
Hi ryanmccauley!

I have tried the solution in the link but as the demo is not exact and I never have worked with iFrames, I cannot complete the example.

However, I have actually found another solution that I can describe for you and possible coming readers!

I have a parent web form and a popup web form (.aspx).

In the parent form I open the popup with RegisterStartupScript in the codebehind and this javascript:

window.open('Popup.aspx', '_blank', 'width=440,height=250,top=312,left=190,scrollbars=0,resizeable=no,title=no')

In the popup I attach this to the button that closes the popup:

btn.Attributes.Add("onclick", "AdjustMotherControls();")

When the user closes the form, some controls on the parent form are changed with Javascript:

<script type="text/javascript">

    function AdjustMotherControls() {
        document.getElementById('lblInfo').innerHTML = 'Some text...'
        mother = opener.document;
        mother.getElementById('ctl00_ContentPlaceHolder1_lblInfo').innerHTML = 'Some other text…';
        mother.getElementById('ctl00_ContentPlaceHolder1_btnSave').disabled = true;
        mother.getElementById('ctl00_ContentPlaceHolder1_btnPrint').disabled = false;
    }

</script>

'ctl00_ContentPlaceHolder1_lblInfo' is the name that Windows assign to the controls in the parent form and I know that you should not use these but I have not been able to find a more correct alternative and these works very well.
0
 
LVL 28

Expert Comment

by:Ryan McCauley
ID: 40051761
Glad to hear it. Does this resolve your original question, or is there still something outstanding that you need addressed?
0
 

Author Comment

by:Kim Neesgaard
ID: 40052822
The described functionality solves the original question. The only 'outstanding' (though it works) is a better way to indicate 'ctl00_ContentPlaceHolder1_lblInfo'. I read on the web that Windows COULD change the name (I have not experienced it) but I could not make the proposals work. However, perhaps this belongs to another question.
0
 

Author Closing Comment

by:Kim Neesgaard
ID: 40103666
Through another source it got information on how to solve this problem and I like to share this solution  with EE so therefore I selected 'my own' answer as the solution.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

810 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