2013-10-24 36 views
0

伙计们我在一个弹出窗口中有一个日历。我需要将选中的日期放入从中打开弹出窗口的页面的文本框中(即在弹出窗口的父页面中)。从另一页面触发页面的方法C#

我已经设置越来越选择在弹出的第一个注册指令,因为

<%@ 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; 
} 

但是我需要日期显示为soo因为它在弹出窗口中被选中。

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

+0

你试过'|上一页.FindControl'? –

+0

这里是MSDN链接的帮助http://msdn.microsoft.com/en-us/library/system.web.ui.page.previouspage.aspx –

+0

你可以使用'SelectionChanged'事件弹出来触发'display() ' –

回答

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> 

希望这将有助于

1

另一种方法相比,Saghir的做法时,这是有点像一个相反的方法。

你有你的父页面打开弹出式页面是这样的:

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

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

在您的弹出页面(calendar.aspx)你写一些像这样的代码:

function sendToParent(value){ 
    //Assume value is assigned from the calendar control 
    //by passing as argument to this function 
    window.opener.populateCalendarTextbox(value); 
    window.close(); 
} 
相关问题