Server Method Failed Error

12 posts, 1 answers
  1. mkasuboski
    mkasuboski avatar
    17 posts
    Member since:
    Jul 2008

    Posted 10 Jul 2009 Link to this post

    I am attempting to create a tooltip for items in a repeater control.  I bind the repeater control to a datatable, and in the ItemDataBound event I add an attribute to a label control within the repeater to execute a javascript function showToolTip for the onmouseover event.

    This is my javascript function:
            function showToolTip(element) { 
                var tooltipManager = $find("<%= RadToolTipManager1.ClientID %>"); 
                 
                if (!tooltipManager) return
                 
                var tooltip = tooltipManager.getToolTipByElement(element); 
                 
                if (!tooltip) { 
                    tooltip = tooltipManager.createToolTip(element); 
                    var partNo = element.innerHTML
                    tooltip.set_value(partNo); 
                } 
                 
                element.onmouseover = null
                 
                try { 
                    tooltip.show(); 
                } 
                catch(ex) { 
                    alert(ex.description); 
                } 
            } 
     

    Here is my toolmanager:
            <telerik:RadToolTipManager  ID="RadToolTipManager1" runat="server"  
                    AutoCloseDelay="10000" Width="160px" Height="70px" 
                    RelativeTo="Element"  
                    Position="MiddleRight" Skin="Outlook"
                <WebServiceSettings Path="GetPartToolTip.asmx" Method="GetPartInfo" /> 
                <TargetControls> 
                    <telerik:ToolTipTargetControl IsClientID="false" TargetControlID="txtFakeTooltip" Value="" /> 
                </TargetControls> 
            </telerik:RadToolTipManager> 
     

    Here is the code for the webservice:
    Imports System.Web 
    Imports System.Web.Services 
    Imports System.Web.Services.Protocols 
    Imports System.ComponentModel 
    Imports System.Web.UI 
    Imports System.Web.UI.WebControls 
    Imports System.Reflection 
    Imports System.IO 
    Imports System.Collections 
     
    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    ' <System.Web.Script.Services.ScriptService()> _ 
    <WebService(Namespace:="http://tempuri.org/")> _ 
    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ 
    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ 
    Public Class GetPartToolTip 
         Inherits System.Web.Services.WebService 
     
        <WebMethod()> _ 
        Public Function GetPartInfo(ByVal context As StringAs String 
     
            Try 
                'Return "Hello" 
                'Dim contextDictionary As IDictionary(Of String, Object) = CType(context, IDictionary(Of String, Object)) 
                'Dim elementID As String = CType(contextDictionary("Value"), String) 
     
                If String.IsNullOrEmpty(context) Then 
                    Throw New Exception("No Value argument is provided to the webservice!"
                End If 
     
                Return ViewManager.RenderView("part_availability.ascx", context) 
            Catch ex As Exception 
                Return "Error occurred in GetPartInfo. Error: " & ex.Message 
            End Try 
        End Function 
     
    End Class 
     
    Public Class ViewManager 
     
        Public Shared Function RenderView(ByVal path As StringByVal partno As StringAs String 
            Dim pageHolder As Page = New Page 
            Dim viewControl As UserControl = CType(pageHolder.LoadControl(path), UserControl) 
     
            Dim viewControlType As Type = viewControl.GetType 
     
            Dim partNbr As FieldInfo = viewControlType.GetField("partno"
            If Not partNbr Is Nothing Then 
                partNbr.SetValue(viewControl, partno) 
            Else 
                Throw New Exception("View file: " & path & " does not have a public 'partno' property"
            End If 
     
            pageHolder.Controls.Add(viewControl) 
            Dim output As StringWriter = New StringWriter 
            HttpContext.Current.Server.Execute(pageHolder, output, False
     
            Return output.ToString 
        End Function 
     
    End Class 

    I added this web service to my web site solution and the code source was stored in the App_Code folder.  I then created a web reference to this web service in my solution.  If I call the Web Service directly, I get a good return string back, but when I call it from within the web application, a pop-up appears stating 'The server method 'GetPartInfo' failed.' 

    Any help on this will be greatly appreciated.

    Thanks!





  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 13 Jul 2009 Link to this post

    Hello mkasuboski,

    The error you get is related to your server code of the web method which populates the tooltip and it is not due to the RadToolTipManager control. What I can suggest is the following:

    1. Make sure that your user control can be correctly loaded without the web service - test it in a simple page.
    2. Try to return a simple string form the web method in order to test the manner you render the result.

    Sincerely yours,
    Svetlina
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mkasuboski
    mkasuboski avatar
    17 posts
    Member since:
    Jul 2008

    Posted 13 Jul 2009 Link to this post

    The problem was in the web service. I needed this "<ScriptService()> _" so that it could take javascript calls.
    I also had to change the public function in the web service, Public Function GetPartInfo(ByVal context As StringAs String  to this, Public Function GetPartInfo(ByVal context As Object) As String

    Now I have this issue, how do I make the javascript pass multiple values instead of one value?

    This is my current javascript that passes one value:
            function showToolTip(element) { 
                var tooltipManager = $find("<%= RadToolTipManager1.ClientID %>"); 
                 
                if (!tooltipManager) return
                 
                var tooltip = tooltipManager.getToolTipByElement(element); 
                 
                if (!tooltip) { 
                    tooltip = tooltipManager.createToolTip(element); 
                    var partNo = element.innerHTML
                    tooltip.set_value(partNo); 
                } 
                 
                element.onmouseover = null
                 
                try { 
                    tooltip.show(); 
                } 
                catch(ex) { 
                    alert(ex.description); 
                } 
            } 
             
     
    So how do I pass multiple values to the web service using the above javascript?

    Thanks.

  5. mkasuboski
    mkasuboski avatar
    17 posts
    Member since:
    Jul 2008

    Posted 15 Jul 2009 Link to this post

    Any thoughts on my previous post about multiple values passed to the web service for doing a tooltip??
  6. Answer
    Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 16 Jul 2009 Link to this post

    Hello mkasuboski,

    I am glad you found the problem with the WebService and you solved it. As to your question - since the RadToolTipManager provides the ability to pass a string, it is up to you how to organize this string. What I suggest is to concatenate all the parameters separated with some separator sign and form one resultant string which contains all the parameters and pass it as a value. After that you should simply split the string according to the used separator on the server and you will get your multiple parameters. This is a standard ASP.NET technique which is not directly related to RadControls  and I believe that it will be helpful in this case.

    Regards,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Javier Perez
    Javier Perez avatar
    2 posts
    Member since:
    Oct 2009

    Posted 30 Oct 2009 Link to this post

    I have a similar problem. However my problem is not due invalid configuration on the WebService Method.

    Here is the scenerio.

    I have a catalog page. OnMouse over a product image we use the RadToolTipManager to call a Webservice method (httpRequest) to get a larger image. When you click on the product you are directed to the product details page. Preaty simple right?

    The Problem:

    1) If you mouseover the product --> http request is invoke --> click on the product --> the http request by the tool tip manger is aborted/timeout because you are no longer in that page --> the alert "The Method 'xxxx' has failed.

    I have look at the javascript and concluded that the RadToolTipManager has no event handler to handle aborts or timeouts in this case from the  XMLHttpExecutor object for the onreadystatechange.
    I am looking for  a way to prevent from showing the alert box with the error message or somehow handle the abort handler by unable to get a reference to the object that initiated the HttpWebRequest.

    To reproduce this issue:

    1) Create a page with the RadToolTipManager.
    2) Create a WebService page with a Method that will take a few second. Do something like Thread.Sleep(5000).
    3) Create a link on the page to take you to another page.
    Run the site.
    1) Mouse over or something to initialize the RadToolTipManger to invoke the webservice call.
    2) Imidiately click on the link to get transfer to the next page.
    3) Right away you will see the alert message with 'The Method 'xxx' failed.'
  8. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 04 Nov 2009 Link to this post

    Hi Javier,

    Indeed, you are correct that in the case you describe a better error handling could be implemented. This is already logged in our TODO list and we will introduce a new client event which will be fired in such cases which will be called OnClientResponseError where the developer can cancel the alert and handle the problem in the desired way. The event will be available in one of the future releases, either in an internal build or in the Service Pack.


    Sincerely yours,
    Svetlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. varun gupta
    varun gupta avatar
    3 posts
    Member since:
    Jan 2010

    Posted 03 Feb 2010 Link to this post

    I am getting this error on mouseover while using tool tip with web service
  10. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 03 Feb 2010 Link to this post

    Hi varun,

    As far as I understand the problem you report is actually that you get an error every time and not that you want to handle a specific case which is the only one when the error occurs. If so, please refer to my previous reply, the following one:

    The error you get is related to your server code of the web method which populates the tooltip and it is not due to the RadToolTipManager control. What I can suggest is the following:

    1. Make sure that your user control can be correctly loaded without the web service - test it in a simple page.
    2. Try to return a simple string form the web method in order to test the manner you render the result.


    If I have not correctly understand you, please provide more detailed explanations.

    All the best,
    Svetlina
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  11. varun gupta
    varun gupta avatar
    3 posts
    Member since:
    Jan 2010

    Posted 05 Feb 2010 Link to this post

    Respected Sir,

    I am using tool tip with image gallery where kitcken,room, toilet etc
    are given .I have not understand how you initialized which one
    will be the area0,area1, area2,area3. furthermore, you have
    initialized javascript at below not on the top of aspx page why.
    When i changed area0 to area1 and area1 to area0,it starts giving photo of
     area1 and area0(vice-versa).Pleas help me in this regard
  12. varun gupta
    varun gupta avatar
    3 posts
    Member since:
    Jan 2010

    Posted 05 Feb 2010 Link to this post

    Respected Sir,

    I am using tool tip with image gallery where kitcken,room, toilet etc
    are given .I have not understand how you initialized which one
    will be the area0,area1, area2,area3. furthermore, you have
    initialized javascript at below not on the top of aspx page why.
    When i changed area0 to area1 and area1 to area0,it starts giving photo of
     area1 and area0(vice-versa).Pleas help me in this regard
  13. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 05 Feb 2010 Link to this post

    Hello varun gupta,

    I am afraid I could not understand you. You reported a problem with failing server method and you did not answer whether you solved it. Now you are talking about areas, IDs and values and I could not understand what is your setup and what is the exact problem you experience. Please, provide detailed and clear explanations and once I have a better understanding on your case I will do my best to help.

    Sincerely yours,
    Svetlina
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017