When i use this code in the page_load it opens the window as expected, when I use it in the itemCommand (and it runs in the debugger) it does not and I dont see any errors?
RadWindow fileWindow = new RadWindow();
fileWindow.NavigateUrl = "http://www.google.com";
fileWindow.VisibleOnPageLoad = true;
fileWindow.ID = "fileWindow1";
fileWindow.Width = 500;
fileWindow.Height = 300;
fileWindow.InitialBehaviors = WindowBehaviors.Maximize | WindowBehaviors.Close | WindowBehaviors.Resize;
RadWindowManager2.Windows.Add(fileWindow);
5 Answers, 1 is accepted
If so then it’s in a postback, and it’s probably losing its value -settings.
Try setting a hiddenField value in the item_command then check the hiddenField value on pageLoad() and based of the hiddenField value run your block of code.
Thanks John
Try checking the hiddenField value in client side JavaScript and open it something like this.
Yes I know its ugly but it works.
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function pageLoad(sender, eventArgs) {
var $ = $telerik.$;
var hid = $get("<%= HiddenFieldConfirm.ClientID%>").value;
if (hid == 1) {
//PLACE YOUR CODE IN THIS BLOCK
$get("<%= HiddenFieldConfirm.ClientID%>").value = 0;
$find("<%= RadWindow1.ClientID%>").show();
}
}
</script>
</telerik:RadScriptBlock>
Simplified but still not sure why necessary, here is what I ended up with that works:
.cs
RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "showFile2('" + path + "' );", true);
.ascx
function showFile2(path) {
var oWindow = window.radopen(path, null, 800, 750, 50, 50);
}
this code works fine in the page_load but does not work in item_Command:
RadWindow fileWindow = new RadWindow();
fileWindow.NavigateUrl = "http://www.google.com";
fileWindow.VisibleOnPageLoad = true;
fileWindow.ID = "fileWindow1";
fileWindow.Width = 500;
fileWindow.Height = 300;
fileWindow.InitialBehaviors = WindowBehaviors.Maximize | WindowBehaviors.Close | WindowBehaviors.Resize;
RadWindowManager2.Windows.Add(fileWindow);
Yes I do something similar for my toastr.js notifications, and other things when I need to kick something off after a postback.
Also don't forget to url encode the path especially if you have &parms.
If you start to have any weird issues try using the ScriptManager.RegisterStartupScript instead of the RadScriptManager even if you are using the Telerik Script Manager
Glad you got it working