Main Objective of this Article

This article shows how to work with Kendo window using the ASP.NET WEB API.

Requirements

Before going through this article ensure that you have a basic understanding of the MVC Architecture, ASP.NET Web API and jQuery.

Create one WEB API application as shown in Figure 1 and 2,

Figure 1
Figure 2

Create Controller: Create an empty controller as in the following figure 3:

Figure 3
  1. [RoutePrefix("api/Kendo")]
  2. public class WindowController : ApiController
  3. {
  4. [HttpGet]
  5. [Route("Window")]
  6. public HttpResponseMessage WindowContent()
  7. {
  8. return Request.CreateResponse(HttpStatusCode.OK, "Hello this is Kendo Window", Configuration.Formatters.JsonFormatter);
  9. }
  10. }

The above controller will return the simple ”Hello this is Kendo window” as a response for the request.

Test the API using POSTMAN/Fiddler:

URI: /api/Kendo/Window

Type: GET

API Response as in the following figure 4,
Figure 4

Consume the API service in Kendo Window

Create one HTML page in the project.

Here is my design:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Untitled</title>
  6. <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.common.min.css">
  7. <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.rtl.min.css">
  8. <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.default.min.css">
  9. <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2016.1.112/styles/kendo.mobile.all.min.css">
  10. <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
  11. <script src="http://kendo.cdn.telerik.com/2016.1.112/js/angular.min.js"></script>
  12. <script src="http://kendo.cdn.telerik.com/2016.1.112/js/jszip.min.js"></script>
  13. <script src="http://kendo.cdn.telerik.com/2016.1.112/js/kendo.all.min.js"></script>
  14. </head>
  15. <style type="text/css">
  16. @media print
  17. {
  18. body *
  19. {
  20. display: none;
  21. }
  22. body .window-prototype
  23. {
  24. display: block;
  25. }
  26. }
  27. </style>
  28. <body>
  29. <div id="print" class="window-prototype"></div>
  30. <button onclick="OpenOrderEntry()">Click</button>
  31. <script>
  32. function OpenOrderEntry()
  33. {
  34. var dialog = $(".window-prototype").kendoWindow
  35. ({
  36. width: "1300px",
  37. height: "280px",
  38. modal: false,
  39. content: "api/Kendo/Window",
  40. resizable: true,
  41. actions: ["Minimize", "Maximize", "Close"],
  42. title: "Kendo Window"
  43. }).data("kendoWindow").open();
  44. }
  45. </script>
  46. </body>
  47. </html>
Result in Browser

I hope you enjoyed this article. Your valuable feedback, question, or comments about this article are always welcome.
Read more articles on ASP.NET: