2010-03-23 104 views
0

基本上,我有一个从父窗口打开的新窗口中的gridview。它有一堆记录和一个查看按钮来查看每条记录的细节(保留在同一个新打开的窗口中)。我在父窗口中有一个日历,它接受一个Date querystring参数来在页面加载时设置日历上的当前日期。我只是想刷新父窗口中的日历以匹配新打开的窗口中的标签日期。将参数作为文本传递给.NET代码隐藏的JavaScript函数

下面的所有代码都在新打开的窗口中。下面的.Net代码涉及点击该视图按钮并填充所有内容。最后,我调用js刷新父窗口,并将LabelScheduleDate的值作为querystring参数传递。现在标签在代码隐藏中以'03/25/2010'的形式出现,但是当我将它传递给js时,它在最后的查询字符串中以'0.00005970149253731343'的形式出现。我不确定是什么让价值变化,我想通过它作为只是文本。我是否需要将它作为字符串对象传递?我试过了,但我认为我没有做对。

谢谢。

JavaScript函数

function RefreshParent(inputDate) { 
    window.opener.location = window.opener.location + "?Date=" + inputDate; 
} 

.NET代码隐藏

Protected Sub RadGridOnlineRequests_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridOnlineRequests.ItemCommand 

    If e.CommandName = "ViewOnlineRequest" Then 

     ' populates LabelScheduleDate among other controls values 
     ScriptManager.RegisterStartupScript(_ 
     Me, Me.GetType(), "clientScript", "RefreshParent(" & LabelScheduleDate.Text & ");", True) 

    End If 

End Sub 

回答

1

所有你需要做的仅仅是为了确保您的渲染脚本将结束与周围的文字引号:

RefreshParent('" & LabelScheduleDate.Text & "'); 

如果LabelScheduleDate.Text的值为“03/25/2010”,则将解析为

RefreshParent('03/25/2010'); 

...而你的代码就已经决心

RefreshParent(03/25/2010); 

...这将意味着RefreshParent接收3除以25除以2010

+0

哈,完全忽略了。谢谢! – ryanulit 2010-03-23 14:45:35

相关问题