0

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

我已经设置了公共访问方法,该方法将在弹出窗口中选择的日期作为第一次注册指令为

<%@ PreviousPageType VirtualPath="~/DateFrom.aspx" %> 

然后在弹出窗口中

//making value of hidden field available to the "destination page"
        public string from
        {
            get
            {
                return hdnFrom.Value.ToString();
            }
        }

我还可以通过以下方法访问父页面上的此值

public string display()
{
    Label1.Text = PreviousPage.from;
}

但是,我需要在弹出窗口中选择日期后立即显示该日期。

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

4

2 回答 2

1

Another approach which is sort of like a reverse approach when compared to Saghir's approach.

You have your parent page open the popup page like this:

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

function populateCalendarTextbox(val){
    document.getElementById('calendarbox').value = val;
}

In your popup page (calendar.aspx) you write some code like this:

function sendToParent(value){
    //Assume value is assigned from the calendar control 
    //by passing as argument to this function
    window.opener.populateCalendarTextbox(value);
    window.close();
}
于 2013-10-29T08:19:33.780 回答
0

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

<script type = "text/javascript">

function childFunc()

{

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

}

</script>

在你的parent.aspx

<script type = "text/javascript">


var PopUpObj;

function popUp(url)

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

function callChildFunc()
{
    if(popUpObj != null && !popUpObj.closed) 
    {
        var val = popUpObj.childFunc();
        alert(val);
    }
}
</script>

希望这会有所帮助

于 2013-10-24T07:39:30.717 回答