How to open a Window from a button

3 posts, 1 answers
  1. Greg Gum
    Greg Gum avatar
    18 posts
    Member since:
    Jun 2009

    Posted 12 Dec 2013 Link to this post

    I have created a window as below.  How do I open this window from a button click?  I have set visible to false so it doesn't show at start up.  How do I then show this window from a button?

    @(Html.Kendo().Window()
    .Name("kendoWindow") //The name of the window is mandatory. It specifies the "id" attribute of the widget.
    .Title("Login") //set the title of the window
    .Content(@<text>
    This is my window.
    </text>)
    .Draggable() //Enable dragging of the window
    .Resizable() //Enable resizing of the window
    .Width(600) //Set width of the window
    .Modal(true)
    .Visible(true)
    )

    Greg
  2. Answer
    Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 12 Dec 2013 Link to this post

    Hi Greg,

    Basically when a Window is initialized its Name is used as and ID for the div containing the information about the widget. This allows you to do the following:    
    @(Html.Kendo().Window()
    .Name("myWindow") //The name of the window is mandatory. It specifies the "id" attribute of the widget.
    .Title("Login") //set the title of the window
    .Content(@<text>
    This is my window.
    </text>)
    .Draggable() //Enable dragging of the window
    .Resizable() //Enable resizing of the window
    .Width(600) //Set width of the window
    .Modal(true)
    .Visible(true)
    )
     
    <button onclick="openWindow()">Open Window</button>
        
    <script>
      function openWindow(){
         var wdw = $("#myWindow").data("kendoWindow"); //get the Window widget's instance
         wdw.open();  //and call its open method
      }
        
    </script>

    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Greg Gum
    Greg Gum avatar
    18 posts
    Member since:
    Jun 2009

    Posted 12 Dec 2013 Link to this post

    Thank you, this was very helpful.
Back to Top