从弹出窗口返回时如何在主页中调用函数 [英] How to call a function in the main page when return from the pop up window

查看:60
本文介绍了从弹出窗口返回时如何在主页中调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在我的项目中,page1.aspx在后面的代码中包含一个按钮和一个函数.单击该按钮时,我必须弹出一个窗口(page2.aspx),并且当弹出窗口关闭时,应该调用page1.aspx.cs中的函数.我该怎么做?我尝试使用javascript函数打开弹出窗口,但是返回后如何调用该函数?

谢谢.

Hi,
In my project, page1.aspx contains a button and a function in code behind. When clicking on the button, I''ve to pop up a window(page2.aspx) and when the pop up window is getting closed function in the page1.aspx.cs should be called. How can I do it? I tried javascript function to open the pop up window, but how will I call the function after return?

Thank you.

推荐答案

You have to write a javascript function in page1.aspx say 'parentFunction()',
in this function you have to call your code behind function.

Now in your pop up window page2.aspx before closing this window
    in javascript call page1.aspx function 'parentFunction()'
using window.opener.parentFunction()


尝试使用委托并相应地触发父页面的事件.
请参考以下链接:
在C#中使用代理的策略 [ C#/.NET中的代理和事件 [ MSDN:代理教程 [
Try using delegates and accordingly fire the event of the parent page.
Refer the links below:
A Strategy for Using Delegates in C#[^]
Delegates and Events in C# / .NET[^]
MSDN : Delegates Tutorial[^]


--Amit


这篇关于从弹出窗口返回时如何在主页中调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆