This is a migrated thread and some comments may be shown as answers.

Launching model radwindow from menuitem not working

4 Answers 44 Views
Window
This is a migrated thread and some comments may be shown as answers.
Hugh
Top achievements
Rank 1
Hugh asked on 17 Nov 2014, 11:55 PM
Hello, very new to Telerik products and am having a difficult time getting the model window to appear from the menuitem,  I am hitting my javascript code ok and now errors are incurred, in fact it appears very briefly.  As you can see from the code below, I also implement via a button which launches fine, but now what I need.  Please help.  thanks

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RavnHost.aspx.cs" Inherits="RAVN_FMEC2.RavnHost" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>RAVN_FMEC2</title>

<%-- <script language="javascript" type="text/javascript" src="Scripts/jquery-1.7.1.min.js"></script>
<script language="javascript" type="text/javascript" src="Scripts/jquery-ui-1.8.20.js"></script>
<script language="javascript" type="text/javascript" src="Scripts/jquery-ui-8.20.min.js"></script>
<script language="javascript" type="text/javascript" src="Scripts/jquery-1.7.1.js"></script>--%>


<script>

function MenuItemClicked(sender, args) {
// var item = args.get_item();

var item1 = args._item._text

if (item1 == "Load") {
var oWindow = $find("RadWindow1");
oWindow.setUrl("LoadRavn.aspx");
oWindow.show();



//openModalWindow();

//var WinSettings = "center:yes;resizable:no;dialogHeight:550px;dialogWidth:500px;";
//var MyArgs = window.showModalDialog("LoadRavn.aspx", MyArgs, WinSettings);

//if (MyArgs == null) {
// window.alert("Nothing returned from Load Dialog. No changes will be made");
//}
//else {
// $("#tbRDCName").val(MyArgs[0].toString());
//}
}
else if (item1 == "Save") {
// var MyArgs = new Array($("#hdnRdcId").val());
// var WinSettings = "center:yes;resizable:no;dialogHeight:600px;dialogWidth:500px;";
// MyArgs = window.showModalDialog("SaveDialog.aspx", MyArgs, WinSettings);

// if (MyArgs == null) {
// window.alert("Nothing returned from Save Dialog. No changes will be made");
// }
// else {
// $("#tbRDCName").val(MyArgs[0].toString());
// }
}
else {
alert("Item with text '" + text + "' not found.");
}
}

function openModalWindow() {
$("#dialog").dialog({
modal: true,
height: 570,
width: 725,
open: true
});
}

function clientShow(sender, eventArgs) {
var txtInput = document.getElementById("txtInput");
sender.argument = txtInput.value;
}
function clientClose(sender, args) {
if (args.get_argument() != null) {
alert("'" + sender.get_name() + "'" + " was closed and returned the following argument: '" + args.get_argument() + "'");
}
}



</script>

</head>

<body>
<form id="form1" runat="server">

<telerik:RadScriptManager ID="ScriptManager1" runat="server" EnableTheming="True">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
</asp:ScriptReference>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
</asp:ScriptReference>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
</asp:ScriptReference>
</Scripts>
</telerik:RadScriptManager>

<asp:Table runat="server" Width="100%">
<asp:TableRow runat="server" Width="100%">
<asp:TableCell runat="server" Width="50%"></asp:TableCell>
<asp:TableCell runat="server" Width="50%" HorizontalAlign="Right">
<asp:Image runat="server" ID="imgNascar" ImageUrl="~/Images/NascarSmall.png" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server" Width="50%" HorizontalAlign="Left" VerticalAlign="Bottom" >
<telerik:RadMenu ID="RadMenu1" OnClientItemClicked="MenuItemClicked" OnItemClick="RadMenu1_ItemClick" runat="server">
<Items>
<telerik:RadMenuItem runat="server" Text="File" >
<Items>
<telerik:RadMenuItem runat="server" Text="Load" >
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" Text="Save">
</telerik:RadMenuItem>
</Items>
</telerik:RadMenuItem>
<telerik:RadMenuItem runat="server" SkinID="Windows7" Text="Print">
</telerik:RadMenuItem>
</Items>
</telerik:RadMenu>&nbsp&nbsp;
<telerik:RadTextBox runat="server" ID="tbRDCName" Width="300px" ></telerik:RadTextBox>
</asp:TableCell>
<asp:TableCell ID="TableCell1" runat="server" Width="50%" HorizontalAlign="Right" >
<asp:Label runat="server" ID="lbUserName" ></asp:Label>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:HiddenField runat="server" ID="hdnRdcId" Value="20" />

<iframe runat="server" id="frameRavn" src="http://30.177.9.11:9050/" width="100%" height="600px" ></iframe>

<telerik:RadWindow ID="RadWindow1" runat="server" Modal="True" NavigateUrl="LoadRavn.aspx"
OnClientClose="clientClose" OnClientShow="clientShow" ReloadOnShow="true"
Height="580px" Width="750px" AutoSizeBehaviors="Width" VisibleStatusbar="False">
</telerik:RadWindow>

<%-- <telerik:RadWindow ID="RadWindow1" runat="server" Modal="True" NavigateUrl="LoadRavn.aspx"
OpenerElementID="showDialog" OnClientClose="clientClose" OnClientShow="clientShow" ReloadOnShow="true" Height="580px" Width="750px" AutoSizeBehaviors="Width" VisibleStatusbar="False">
</telerik:RadWindow> --%>

Type initial value here:
<br />
<asp:TextBox ID="txtInput" runat="server" /><br />
<asp:Button ID="showDialog" Text="Show Dialog" runat="server" />



</form>
</body>
</html>

4 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 18 Nov 2014, 02:00 PM

Hi Steve,

You must prevent the postback that disposes the RadWIndow, because its markup is generated with JavaScript and when the control disposes, it will not be recreated and thus, it will effectively close.

Here follows a sample that highlights the changes:

  • the OnClientItemClicking event is used
  • the event is cancelled when needed via the args.set_cancel(true); call
  • the public API of the event arguments objects is used

<telerik:RadMenu ID="RadMenu1" OnClientItemClicking="MenuItemClicking" OnItemClick="RadMenu1_ItemClick" runat="server">
    <Items>
        <telerik:RadMenuItem runat="server" Text="File">
            <Items>
                <telerik:RadMenuItem runat="server" Text="Load">
                </telerik:RadMenuItem>
                <telerik:RadMenuItem runat="server" Text="Save">
                </telerik:RadMenuItem>
            </Items>
        </telerik:RadMenuItem>
        <telerik:RadMenuItem runat="server" SkinID="Windows7" Text="Print">
        </telerik:RadMenuItem>
    </Items>
</telerik:RadMenu>

function MenuItemClicking(sender, args) {
    // var item = args.get_item();
    var item1 = args.get_item().get_text();
 
    if (item1 == "Load") {
        args.set_cancel(true);
        var oWindow = $find("<%=RadWindow1.ClientID%>");
        oWindow.setUrl("LoadRavn.aspx");
        oWindow.show();
    } else if (item1 == "Save") {
 
    } else {
        alert("Item with text '" + text + "' not found.");
    }
}


Regards, Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Hugh
Top achievements
Rank 1
answered on 18 Nov 2014, 06:22 PM
Thanks very much Marin, I really appreciate the quick response.  

FYI- In addition I have to move my js code into the form tag as VS2012 could not handle the inline script tags <%= %>.

Unfortunately I am having another issue on the child which I hope you could assist with.  

in the GetRadWindow function, I cannot create the Owindow object when loading the  child page thus preventing me from passing values to the child popup, yet when closing the page this funciton works fine enabling me to pass variable back to the parent page.

 Below is my code.
            function pageLoad() {
                txtInput = document.getElementById('RDCHolder');
                var currentWindow = GetRadWindow();
                txtInput.value = currentWindow.argument;
            }

            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow)
                    oWindow = window.radWindow;
                else if (window.frameElement.radWindow)
                    oWindow = window.frameElement.radWindow;
                return oWindow;

Thanks,
Steve
0
Marin Bratanov
Telerik team
answered on 19 Nov 2014, 04:44 PM

Hi Steve,

For the server code blocks - you can wrap the scripts in a RadCodeBlock tag: http://www.telerik.com/help/aspnet-ajax/ajax-radscriptblock-radcodeblock.html.

On the second query - as I said in your other two threads on the matter - I am not aware of reasons for this common function to fail and what I can advise is the following:

If you still cannot resolve this, the best course of action is to open a support ticket and send us a fully runnable sample where we can observe the issue in order to debug it and offer a better response.


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Hugh
Top achievements
Rank 1
answered on 23 Nov 2014, 06:21 AM
Thanks again,

I changed from an asp script manager to the radscriptmanager and seem to work ok.
Tags
Window
Asked by
Hugh
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Hugh
Top achievements
Rank 1
Share this question
or