I have been trying to get a RadWindow I have defined on my page to open via a javascript script block I register as part of a button postback. (see code below). My page lives inside of a master page, so I don't know if that has an impact or not, but when I execute the following line:
var oWnd = $find("rwRegisterCardPopup");
my oWnd is null.
.aspx code
-------------------------
<script type="text/javascript">
<!--
function CallbackFunction_rwRegisterCardPopup(win, val)
{
var hfReturn = document.getElementById('<%= hfRegisterWindowCallback.ClientID %>');
var btn = document.getElementById('<%= btnRegisterWindowCallback.ClientId %>');
hfReturn.value = val;
btn.click();
}
function OpenPopUp_rwRegisterCardPopup(ProductId, SupplierId, Discount)
{
var oWin = $find("rwRegisterCardPopup");
if (oWin == null)
{
alert(
'Error: oWin == null is true (method1)'); //this always shows as oWin is null
oWin = $find(
"<%=rwRegisterCardPopup.ClientID%>");
}
if (oWin == null)
alert(
'Error: oWin == null is true (method2)'); //this always shows as oWin is null
else
{
var url = oWin.get_navigateUrl();
url = url +
"?GLSCProductId=" + ProductId + "&GLSCSupplierId=" + SupplierId + "&Discount=" + Discount;
oWin.setUrl(url);
oWin.show();
oWin.center();
}
}
-->
</script>
<telerik:RadWindow ID="rwRegisterCardPopup" runat="server" Title="New Reloadable Card Registration" Modal="true" Height="600px" Width="400px" Skin="WebBlue" Behaviors="Move" VisibleStatusbar="false" ClientCallBackFunction="CallbackFunction_rwRegisterCardPopup" NavigateUrl="~/orderscrip/register_card.aspx" >
</telerik:RadWindow>
.....
here's my code behind for the button that registers the Client Script Block
Private Sub ShowRegisterCardPopup(ByVal GLSCProductId As String, ByVal GLSCSupplierId As String, ByVal Discount As Decimal)
Dim java As String = "<script>alert('calling OpenPopUp_rwRegisterCardPopup()'); OpenPopUp_rwRegisterCardPopup('{0}', '{1}', '{2}');</" & "script>"
Me.ClientScript.RegisterStartupScript(Me.GetType(), "ShowRegisterCardPopup", String.Format(java, GLSCProductId, GLSCSupplierId, Discount))
End Sub
The Sub is the only code called by the button's Click handler.
My page inherits the Asp.net AJAX ScriptManager from the master page.
I tried adding the RadWindowManger and using the radopen method as well, but had no improvement with the results.
Please advise.
thanks,
Paul

Suppose you want to bind a grid for asp.net in a user control to an ObjectDatasource.
It is a problem if the subroutine for the SelectMethod of the ObjectDatasource has a parameter whose value depends on user context or on a value in another control on the user control.
You cannot get this parameter value in the code-behind of the user control. For example, the subroutine for the SelectMethod could be in the code-behind of the user control.
BUT it will not work. Because the ObjectDatasource activates this subroutine before there is any user context or any viewstate available in the user control.
So you cannot get the parameter value this way.
I solved the problem by:
1. Defining a label control (lblSCS_ID in this case ) in the user control that will be the source of the parameter value
<asp:ObjectDataSource ID="ObjDataSourceGetPGC2forSCS_ID" runat="server" TypeName="BalancedFlow.Library.Manager.SCSManager"
SelectMethod="GetPGC2forSCS" EnablePaging="false">
<SelectParameters>
<asp:ControlParameter Name="SCS_ID" ControlID="lblSCS_ID" PropertyName="Text" />
</SelectParameters>
2. In the OnPreRender of the code-behind of the user control I set the value of the parameter.
lblSCS_ID.Text = UserContext.Session.ScsId.Value.ToString();
Now when the ObjectDatasource activates the SelectMethod it will get the parameter value from lblSCS_ID.Text (The parametervalue will already be there).


| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title>Untitled Page</title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <asp:ScriptManager ID="ScriptManager1" runat="server"> |
| </asp:ScriptManager> |
| <telerik:RadComboBox ID="RadComboBox1" runat="server" DropDownWidth="300px" Height="150"> |
| <Items><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /><telerik:RadComboBoxItem Text="asdasdas das d asd as d as d as d asdasd as d" Value="" /></Items> |
| </telerik:RadComboBox> |
| </div> |
| </form> |
| </body> |
| </html> |

