Reputation:
My Code:
<asp:ImageButton ID="btnAddReport" runat="server" OnClientClick="return AddFavoritePopup()"
ImageUrl="~/Content/images/add_favorite.jpg" Width="24px" Height="20px"
style="vertical-align:middle"/>
function AddFavoritePopup() {
var radWindow = document.getElementById('AddFavoriteRadWindow');
radWindow.show()
}
<telerik:RadWindowManager runat="server" ID="RadWindowManager2" Title="Add Favorite"
Behaviors="Close" VisibleStatusbar="False" Modal="False">
<Windows>
<telerik:RadWindow ID="AddFavoriteRadWindow" Width="500" Height="300" VisibleOnPageLoad="false" CssClass="radwindow" runat="server">
<ContentTemplate>
<table>
<tr>
<asp:Label ID="lblFavorite" runat="server" Text="Favorites: "></asp:Label>
<asp:TextBox ID="txtReportFavorite" runat="server"></asp:TextBox>
</tr>
<tr>
<asp:Button ID="btnOk" runat="server" Text="OK" Width="50" Height="25" onclick="btnOk_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="50" Height="25" onclick="btnCancel_Click" />
</tr>
</table>
</ContentTemplate>
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
How to open RadWindow in the script. I tried with show function. It is not opening. Thanks.
Upvotes: 3
Views: 14848
Reputation: 772
The window does not appear because when the code is executed, not all controls on the page are fully rendered yet.
What you can do to avoid that is to use the Sys.Application.add_load function to hook to the ShowWindow function to the load event e.g :
protected void Button1_Click(object sender, EventArgs e)
{
string script = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(ShowWindow);</script>";
ClientScript.RegisterStartupScript(this.GetType(), "showWindoww", script);
}
Click here for more details regarding Sys.Application.add_load
Thanks.
Upvotes: 1
Reputation: 3798
try this
var oWnd = $find("<%=AddFavoriteRadWindow.ClientID%>");
oWnd.show();
or alternate
var oManager = GetRadWindowManager();
oManager.open(null, "AddFavoriteRadWindow");
Upvotes: 2