Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to call parent page button event from popup window or child page.

Posted on 2010-09-13
8
Medium Priority
?
1,015 Views
Last Modified: 2012-05-10
hi,
i have a event in parent.aspx. named savedata.
when i click on save data a popup  should be opened.
In popup window(popup.aspx there is a event called Close.
in that close event ineed to call the parentpage's savedata event.
pls giveme the code for the above scinnario
With Regards
Ravi
0
Comment
Question by:mu_ravi1
[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
8 Comments
 
LVL 21

Expert Comment

by:chapmanjw
ID: 33664642
0
 
LVL 5

Expert Comment

by:milindsaraswala
ID: 33664674
hi Ravi
every page in asp.net is a class. so from Page 2, you can use the following
code:

dim myPage1 as new Page1()
myPage1.FunctionWhatever()

you must understand though that you would just be creating a page object
with a scope/lifetime limited to the current block of code you are in (e.g.
Page2.button_ok_click).

what you should really do in your situation is organise your code better.
if you have shared code that is needed by Page1 and Page2 then it should be
in a class of its own. if you're using .Net2, just put a new class file
into App_Code which is the shared code folder. otherwise just insert a new
class anywhere in the application, then it can be used by any page in your
site, without having to go creating Page objects just to use the code
contained in them. the code i've written above is a really poor way of
sharing code between pages, unless it is absolutely necessary, and even then
i can't think of a good reason why you would want to do this. just suppose
that later on in the development of your site, you decide to delete Page1,
but ooops you forgot you had code in there that Page2 is dependent on, so
you break the site and have to pull out the code.

a page should be encapsulated, without having dependencies on other pages.
otherwise you will end up with a monster of a web site with so many
inter-dependencies between pages that it will be very difficult to maintain.

Milind
0
 
LVL 9

Expert Comment

by:abhinayp86
ID: 33666240
Yup... here is the code.


VB or C#?

I put C# version here.

btnSave is the ID of ur Parent save button
In the aspx of the child page (head), put this

  <script type ="text/javascript" language="javascript" > 
function callParentClick() {
       window.opener.document.getElementById('<%=btnSave.ClientID%>').click();
      }
</script>

------------------------

In the button click event of the close button(code behind .cs file) put this

 ClientScript.RegisterStartupScript(this.GetType(), "CallParent", "callParentClick();", true);

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mu_ravi1
ID: 33670296
Hi all,

My question is for using delegates or event handling.

i have a event in parent.aspx. named savedata.
when i click on savedata Button a popup  should be opened.
In popup window(popup.aspx there is a event called with CloseButton.
in that close event i need to call the parentpage's savedata Button event.
pls giveme the code for the above scinnario
Regards
ravi
0
 
LVL 3

Expert Comment

by:vusov
ID: 33671382
Does your popup is called from server side? If yes you dont need to call  savedata Button event. You should store all data in the session and then read it on the popup CloseButton click.
//parent page
private void SavedataButton_OnClick()
{
   Session["Data"] = ....
}

//popup page

private void CloseButton_OnClick()
{
   object data = Session["Data"];
}

Open in new window

0
 
LVL 9

Accepted Solution

by:
abhinayp86 earned 750 total points
ID: 33672877
@ravi.
My code does the exact same thing u r askin for.
0
 

Author Closing Comment

by:mu_ravi1
ID: 33679561
I used the concept and implemented differentely
0
 
LVL 9

Expert Comment

by:abhinayp86
ID: 33681539
No probs :)
All that matters is you found ur answer.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 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