views:

590

answers:

1

Basically, I have a gridview that is opened in a new window from the parent window. It has a bunch of records with a view button to view the details of each record (which stays in the same newly opened window). I have a calendar in the parent window that accepts a Date querystring parameter to set the current date on the calendar at page load. I'm just trying to refresh the calendar in the parent window to match the date of the label in the newly opened window.

All the code below is in the newly opened window. The .Net code-behind below refers to when that view button is clicked and everything is populated. At the end, I call the js to refresh the parent window and pass the value of the LabelScheduleDate as the querystring parameter. Now the label comes through as '03/25/2010' in the code-behind, but when I pass it to the js, it comes through as '0.00005970149253731343' in the end querystring. I'm not really sure what is making the value change, and I want to pass it as just text. Do I need to pass it as a string object? I tried but I don't think I was doing it right.

Thanks.

JavaScript Function

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

.NET Code-Behind

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  A: 

All you have to do is simply to make sure that your rendered script will end up with quotes around the text:

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

If LabelScheduleDate.Text has the value "03/25/2010", this will resolve to

RefreshParent('03/25/2010');

...whereas your code would've resolved to

RefreshParent(03/25/2010);

...which would mean that RefreshParent receives 3 divided by 25 divided by 2010.

David Hedlund
Ha, totally overlooked that. Thanks!
ryanulit