kendo window handle events on server-side

5 posts, 1 answers
  1. marco
    marco avatar
    17 posts
    Member since:
    Apr 2013

    Posted 19 Sep 2013 Link to this post

    Hello Dimo,
    thanks for your reply, which allowed me a leap forward.
    Now I understand that to get events from the kendo window in the code-behind I must append the window to the form and
    why initially the window is outside.
    I added appendTo("form#myform") as configuration option in the creation of the window.The window has a button.
    Now I have only one window and I get the button click event in the code-behind.
    I have a further question though:
    1.
    Still I think I'm confusing jquery appendTo and kendowindow appendTo.
    The kendowindow appendTo(form) is a configuration option when I create the window. If I create the window without this option,
    in the javascript button handler I will call always the jquery appendTo(form) which will always duplicate the window correct ?
    So My only option then is to appendTo(form) when I create the window, correct ?

    2.
    Now the close doesn't give any error but I have the following situation:
    Javascript handler
            <script language="javascript" type="text/javascript">
                $(document).ready(function () {
                    $("#dialogLogout").kendoWindow({
                        draggable: true,
                        height: "300px",
                        modal: true,
                        resizable: false,
                        width: "600px",
                        actions: ["Minimize", "Maximize", "Close"],
                        appendTo: "form#form1"
                    });
                    var wnd = $("#dialogLogout").data("kendoWindow");
                    $("#btnLogoutConfirmOK").bind("click", function () {
          //                    window.parent.$("#dialogLogout").data("kendoWindow").close();
                        //                    $("#dialogLogout").closest(".k-window-content").data("kendoWindow").close();
                        $("#dialogLogout").data("kendoWindow").close();
                    });
                });
            </script> 
    The code behind is something like this (I added a sleep of 5 seconds to simulate a long operation).
            protected void btnLogoutConfirmOK_Click(object sender, EventArgs e)
            {
                 System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(5).TotalMilliseconds);
            }
    The behavior seems
    I click the button, the javascript handler is called,
    The window closes, either of the 3 close statements give the same effect,
    the server-side handler is called, waits for 5 seconds, it returns and forces the reopen of the window.
    How can I close the window programmatically ?

    Thank you for your kind attention,
    best regards
    Marco  
  2. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 20 Sep 2013 Link to this post

    Hello Marco,

    Here are some guidelines on your questions:

    1. Why the Window is outside the form.

    The Kendo UI widgets are server-platform-agnostic, that's why the Window does not rely on an existing ASP.NET form and by default resides as a child of the <body> element.

    2. The appendTo("form") method has the effect of adding another window

    Please don't confuse the jQuery appendTo() method with the Kendo UI Window appendTo configuration option.

    http://docs.kendoui.com/api/web/window#configuration-appendTo

    In case there is misleading information somewhere on our website, please tell us where it is, so that we can edit the text.

    3. The "options is not an object" error is probably caused by the duplication of the Window on the page, which results in invalid client object references. I suppose the error will disappear when you fix the appendTo problem.

    Regards,
    Dimo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. marco
    marco avatar
    17 posts
    Member since:
    Apr 2013

    Posted 23 Sep 2013 Link to this post

    Hello Dimo,
    thanks for your reply, which allowed me a leap forward.
    Now I understand that to get events from the kendo window in the code-behind I must append the window to the form and
    why initially the window is outside.
    I added appendTo("form#myform") as configuration option in the creation of the window.The window has a button.
    Now I have only one window and I get the button click event in the code-behind.
    I have a further question though:
    Still I think I'm confusing jquery appendTo and kendowindow appendTo.
    The kendowindow appendTo(form) is a configuration option when I create the window.If I create the window without this option,
    in the javascript button handler I call always the jquery appendTo(form) which will always duplicate the window correct ?
    Now the close doesn't give any error but I have the following situation:
    Javascript handler
            <script language="javascript" type="text/javascript">
                $(document).ready(function () {
                    $("#dialogLogout").kendoWindow({
                        draggable: true,
                        height: "300px",
                        modal: true,
                        resizable: false,
                        width: "600px",
                        actions: ["Minimize", "Maximize", "Close"],
                        appendTo: "form#form1"
                    });
                    var wnd = $("#dialogLogout").data("kendoWindow");
                    $("#btnLogoutConfirmOK").bind("click", function () {
          //                    window.parent.$("#dialogLogout").data("kendoWindow").close();
                        //                    $("#dialogLogout").closest(".k-window-content").data("kendoWindow").close();
                        $("#dialogLogout").data("kendoWindow").close();
                    });
                });
            </script> 
    The code behind is something like this (I added a sleep of 5 seconds to simulate a long operation).
            protected void btnLogoutConfirmOK_Click(object sender, EventArgs e)
            {
                 System.Threading.Thread.Sleep((int)System.TimeSpan.FromSeconds(5).TotalMilliseconds);
            }
    The behavior seems
    I click the button, the javascript handler is called,
    The window closes, either of the 3 close statements give the same effect,
    the server-side handler is called, waits for 5 seconds, it returns and forces the reopen of the window.
    How can I close the window programmatically ?
    Thank you for your kind attention,
    best regards
    Marco  
  5. Answer
    Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 23 Sep 2013 Link to this post

    Hello Marco,

    The Kendo UI Window can be closed programmatically only via Javascript and the widget object's close() method, which you are already aware of.

    However, I think the problem is in the current algorithm, which creates and opens the Window unconditionally, even when it is not needed. I advise you to work on that logic and more importantly, think outside the ASP.NET WebForms paradigm, because the Kendo UI Window evidently does not have a server-side object to manipulate in code-behind directly.

    Regards,
    Dimo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. marco
    marco avatar
    17 posts
    Member since:
    Apr 2013

    Posted 23 Sep 2013 Link to this post

    Thanks for your suggestions Dimo.
    Best regards

    Marco
Back to Top
Kendo UI is VS 2017 Ready