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

Server-side button click event handler within Kendo UI Window

2 Answers 409 Views
Window
This is a migrated thread and some comments may be shown as answers.
Francois
Top achievements
Rank 1
Francois asked on 03 May 2012, 08:20 PM
How do I handle a server-side click event for a button within a Kendo UI window?

My problem is that whenever I click on button "btnLogoutConfirmOK" (see code below), nothing happens.

Here is the markup for my window:

<div id="dialogLogoutConfirm" class="Dialog" style="display: none">
    <br />
    <div style="height: 20%; text-align: center">
        <asp:Label ID="lblLogoutConfirm" runat="server" CssClass="label-dialog" Text="Sign out of DMS?"></asp:Label>
    </div>
    <br />
    <br />
    <div style="text-align: center;">
        <asp:Button ID="btnLogoutConfirmCancel" runat="server" Text="No" Width="100px" />
        <asp:Button ID="btnLogoutConfirmOK" runat="server" Text="Yes" Width="100px" />
    </div>
</div>


Here is the script that opens the KendoUI window:

$("#dialogLogoutConfirm").kendoWindow(windowOptions);
 
$("#<%=imgLogout.ClientID %>").click(function () {
 
    var window = $("#dialogLogoutConfirm").css("display", "block").data("kendoWindow");
    var title = window.wrapper.find('.k-window-title');
    title.html('<label style="font-size: large; color: #0; text-align:center;"><b>Sign Out</b></label>');
 
    $("#<%= btnLogoutConfirmCancel.ClientID%>").bind("click", function () {
        window.close();
        return false;
    });
 
    window.center();
    window.open();
    return false;
});

and here is the server-side event handler for button "btnLogoutConfirmOK":

Protected Sub btnLogoutConfirm_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogoutConfirmOK.Click
    Dim us As UserSession = UserSession.Retrieve(Session("intUserSessionId"))
    With us
        .SessionLogoutDate = DateTime.Now
        .Update()
    End With
    Session("intAgentID") = Nothing
    Session("intUserID") = Nothing
    Session("UserSecurityTask") = Nothing
    Session("GlobalSearchCriteria") = Nothing
    Response.Redirect("~/Login.aspx")
End Sub

2 Answers, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 04 May 2012, 07:58 AM
Hello Francois,

The buttons do not work because the window is moved just before the </body> tag when it is initialized -- thus, the buttons are outside the <form runat="server"> when they are clicked. You can work-around that by moving the window inside the form at the right moment, just before posting:

$(".Dialog button").click(function() {
    $(this).closest(".Dialog").appendTo("form");
});

(note that the click event might be too late -- in that case, try the mousedown event).

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Francois
Top achievements
Rank 1
answered on 04 May 2012, 01:55 PM
Thanks, worked perfectly!
Tags
Window
Asked by
Francois
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Francois
Top achievements
Rank 1
Share this question
or