Solved

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

Posted on 2014-03-26
5
252 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

763 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

7 Experts available now in Live!

Get 1:1 Help Now