C# 从另一个页面C触发一个页面的方法#

C# 从另一个页面C触发一个页面的方法#,c#,asp.net,triggers,webpage,C#,Asp.net,Triggers,Webpage,伙计们,我在弹出窗口上有一个日历。我需要在弹出窗口打开的页面(即弹出窗口的父页面)的文本框中选择日期 我已经设置了公共访问方法,将弹出窗口上选择的日期设置为首次将指令注册为 <%@ PreviousPageType VirtualPath="~/DateFrom.aspx" %> 我还可以通过以下方法在父页面上访问此值: public string display() { Label1.Text = PreviousPage.from; } 然而,我需要的日期显示,一旦

伙计们,我在弹出窗口上有一个日历。我需要在弹出窗口打开的页面(即弹出窗口的父页面)的文本框中选择日期

我已经设置了公共访问方法,将弹出窗口上选择的日期设置为首次将指令注册为

<%@ PreviousPageType VirtualPath="~/DateFrom.aspx" %> 
我还可以通过以下方法在父页面上访问此值:

public string display()
{
    Label1.Text = PreviousPage.from;
}
然而,我需要的日期显示,一旦它是在弹出窗口中选择


如何从弹出窗口触发
display()

您可以使用javascript将值从子弹出窗口发送到父网页 这是您的
子.aspx的脚本

<script type = "text/javascript">

function childFunc()

{

    return document.getElementById ("<%Calender1.ClientID%>").value;

}

</script>
<script type = "text/javascript">


var PopUpObj;

function popUp(url)
{ PopUpObj=window.open(url); PopUpObj.focus(); }

函数callChildFunc()
{
if(popUpObj!=null&!popUpObj.closed)
{
var val=popUpObj.childFunc();
警报(val);
}
}

希望这将有助于

另一种方法,这种方法与我们的方法相比有点像是相反的方法

您让您的父页面按如下方式打开弹出页面:

function openCalendar(){
    window.open('calendar.aspx', '_blank', 'width=200,height=100');
}

function populateCalendarTextbox(val){
    document.getElementById('calendarbox').value = val;
}
function sendToParent(value){
    //Assume value is assigned from the calendar control 
    //by passing as argument to this function
    window.opener.populateCalendarTextbox(value);
    window.close();
}
在弹出页面(calendar.aspx)中,您可以编写如下代码:

function openCalendar(){
    window.open('calendar.aspx', '_blank', 'width=200,height=100');
}

function populateCalendarTextbox(val){
    document.getElementById('calendarbox').value = val;
}
function sendToParent(value){
    //Assume value is assigned from the calendar control 
    //by passing as argument to this function
    window.opener.populateCalendarTextbox(value);
    window.close();
}

您是否尝试过
上一页。FindControl
?这里是msdn链接,您可以使用弹出窗口中的
SelectionChanged
事件触发
display()
@Saghir A.Khatri,我无法执行此操作,因为该方法位于不同的页面中。如何将其注册到弹出窗口,以便从opoupSave selected date in session变量触发它,并在您想要访问它的页面中使用该会话变量。