Can the panel be used with a WebMethod in an aspx.cs?

4 posts, 2 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 15 Sep 2010 Link to this post

    Title says it all....the amount of asmx files I'm accumulating becasue I use (overuse? :) the RadXmlHttpPanel is getting a little crazy.

    Can I do a quick one or two in the page with a WebMethod? 
  2. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 17 Sep 2010 Link to this post

    Hello Steve,

    Indeed this is possible, and we will document this feature as soon as we can. It is done in the following way:

    1. Set EnablePageMethods="true" to the ScriptManager control on the page.
    2. Set RadXmlHttpPanel's WebMethodPath property to the path of the page containing the method in its code behind.
    3. Make sure the method is a static one (shared in VB).
    4. Make sure the method is marked as WebMethod

    For your convenience I have created a simple page demonstrating this. Here is the code:

    .aspx
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PAGE_WebService.aspx.cs"
        Inherits="Default_Callback" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head id="Head1" runat="server">
        <title></title>
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
            <script type="text/javascript">
                function SetValue()
                {
                    var panel = $find("<%=XmlPanel1.ClientID %>");
                    panel.set_value("Some Value");
                }
            </script>
        </telerik:RadScriptBlock>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>
        <div>
            <input value="Set Value" onclick="SetValue(); return false;" type="button" />
            <telerik:RadXmlHttpPanel ID="XmlPanel1" runat="server" EnableClientScriptEvaluation="true"
                WebMethodName="HelloWorld" WebMethodPath="~/PAGE_WebService.aspx">
            </telerik:RadXmlHttpPanel>
        </div>
        </form>
    </body>
    </html>


    .cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Script.Serialization;
    using System.Web.Services;
     
     
    public partial class Default_Callback : System.Web.UI.Page
    {
        [WebMethod]
        public static string HelloWorld()
        {
            return "Hello World called at:" + DateTime.Now.ToString();
        }
    }

    Regards,
    Pero
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 17 Sep 2010 Link to this post

    That's great news!

    Now let me throw you for another loops ;)

    Can it be done inside a Composite Control :D  What I'm doing in my Composites right now is exposing the path as a public property and in my page pointing that at an external ASMX whos class points back to the Assembly which contains the service.
  5. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 22 Sep 2010 Link to this post

    Hello Steve,

    I believe that this is not possible, because your custom composite control must inherit from System.Web.Services.WebService and System.Web.UI.WebControls.CompositeControl. This is not possible with C# and VB.NET, because they do not support multiple inheritance, which means that you cannot inherit from multiple base classes. WebService and CompositeControl are both base classes, and you can derive only one of them.

    Greetings,
    Pero
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top