Solved

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

Posted on 2014-03-26
5
268 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
[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
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to open text file 11 136
"Black Box" Testing of Control System Software 2 96
How to Have Macro Files Automatically "Edit" 5 50
convert Systemjs to Webpack 3 83
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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?
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.
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…

726 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