Web Service Help

4 posts, 1 answers
  1. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 23 Mar 2012 Link to this post

    I am new to the HTML5 and Kendo UI stuff. is there any Hello World Example for accessing a web service
    and returning the String to a div.


    Thank you
  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 23 Mar 2012 Link to this post

    Hi,

    You can use the jQuery load methods to do this:

    $('#result').load('WebService.asmx/Method');

    You can find more info in this blog post.

    Regards,
    Atanas Korchev
    the Telerik team
    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. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 23 Mar 2012 Link to this post

    HTML Code
    <html>
    <head>
        <title>DSR v2.0 Login</title>
        <script src="js/jquery.min.js" type="text/javascript"></script>
        <script src="js/kendo.web.min.js" type="text/javascript"></script>
        <script src="content/shared/js/console.js" type="text/javascript"></script>
        <link href="styles/kendo.common.min.css" rel="stylesheet" />
        <link href="styles/kendo.default.min.css" rel="stylesheet" />
    </head>
    <body>
         
        <script type="text/javascript">
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "DSR.asmx/HelloWorld",
                success: function (msg) {
                    alert(msg.d);
                },
                error: function (msg) {
                    alert(msg.d);
                }
            });
        </script>
    </body>
    </html>

    Web Service
    Imports System.Web.Services
    Imports System.Web.Services.Protocols
    Imports System.ComponentModel
     
    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    ' <System.Web.Script.Services.ScriptService()> _
    <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <ToolboxItem(False)> _
    Public Class DSR
        Inherits System.Web.Services.WebService
     
        <WebMethod()> _
        Public Function HelloWorld() As String
           Return "Hello World"
        End Function
     
    End Class


    alert box comes back with undefined and Not Hello World.

    What am i missing..........

    Thank you for the help
  5. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 26 Mar 2012 Link to this post

    i got it..
    need to add
    <WebMethod(EnableSession:=True)> _
        <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>

     to your web service

    and import 
    Imports System.Web.Script.Services

    and make sure that you allow a service to be called from script.
    From this:
    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    '<System.Web.Script.Services.ScriptService()> _
    <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <ToolboxItem(False)> _
     
    to This
    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    <System.Web.Script.Services.ScriptService()> _
    <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <ToolboxItem(False)> _

Back to Top
Kendo UI is VS 2017 Ready