This is a migrated thread and some comments may be shown as answers.

Server Method Failed Error

11 Answers 270 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
mkasuboski
Top achievements
Rank 1
mkasuboski asked on 10 Jul 2009, 09:03 PM
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!





11 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 13 Jul 2009, 02:26 PM
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.
0
mkasuboski
Top achievements
Rank 1
answered on 13 Jul 2009, 06:44 PM
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.

0
mkasuboski
Top achievements
Rank 1
answered on 15 Jul 2009, 12:37 PM
Any thoughts on my previous post about multiple values passed to the web service for doing a tooltip??
0
Accepted
Svetlina Anati
Telerik team
answered on 16 Jul 2009, 08:45 AM
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.
0
Javier Perez
Top achievements
Rank 1
answered on 30 Oct 2009, 01:46 PM
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.'
0
Svetlina Anati
Telerik team
answered on 04 Nov 2009, 01:02 PM
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.
0
varun gupta
Top achievements
Rank 1
answered on 03 Feb 2010, 12:09 PM
I am getting this error on mouseover while using tool tip with web service
0
Svetlina Anati
Telerik team
answered on 03 Feb 2010, 04:05 PM
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.
0
varun gupta
Top achievements
Rank 1
answered on 05 Feb 2010, 09:53 AM
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
0
varun gupta
Top achievements
Rank 1
answered on 05 Feb 2010, 09:58 AM
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
0
Svetlina Anati
Telerik team
answered on 05 Feb 2010, 03:03 PM
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.
Tags
ToolTip
Asked by
mkasuboski
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
mkasuboski
Top achievements
Rank 1
Javier Perez
Top achievements
Rank 1
varun gupta
Top achievements
Rank 1
Share this question
or