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:
Here is my toolmanager:
Here is the code for the webservice:
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!
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 String) As 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 String, ByVal partno As String) As 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!