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

x
?
Solved

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

Posted on 2014-03-26
5
Medium Priority
?
295 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
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.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Introduction to Processes

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