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

Problem with Tooltipified RadGrid Demo in VB

2 Answers 14 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tomica
Top achievements
Rank 2
Tomica asked on 27 Aug 2012, 12:46 AM
I have copied the source code from the VB version of the demo which demonstrates how to pop up a custom control with database content.

I also duplicated the database tables.

I can get 95% of the way, and then I find an error that makes no sense to me. The attached screen shot indicates a problem with creating an instance of the custom control as "ProductDetailsVB" not defined. This is actually detected in VS2010, but I ran the code to create a better error description.

I have confirmed that the ASCX control works with static placement on another page. In order to run the demo code, I have commented out two lines "Dim Details as ProductDetailsVB..." and "details.ProductID. When I do this I get the appropriate behavior for the popup control, minus actual database content because it is not receiving the ProductID.

I have created the control as "ProductDetailsVB.ascx" to match the source code. But I do note that the online demo references "ProductDetailsCS.ascx" which would not be appropriate for a VB programmer such as myself.

This is my first custom control, and I have no clues as to the error, and am doubly confused over the reference to CS in a VB demo.
Partial Class pop2
    Inherits System.Web.UI.Page
    Protected Sub OnAjaxUpdate(sender As Object, args As ToolTipUpdateEventArgs)
        Me.UpdateToolTip(args.Value, args.UpdatePanel)
    End Sub
    Private Sub UpdateToolTip(elementID As String, panel As UpdatePanel)
        Dim ctrl As Control = Page.LoadControl("ProductDetailsvb.ascx")
        panel.ContentTemplateContainer.Controls.Add(ctrl)
        Dim details As ProductDetailsVB = DirectCast(ctrl, ProductDetailsVB)
        details.ProductID = elementID
    End Sub
    Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
        If e.Item.ItemType = GridItemType.Item OrElse e.Item.ItemType = GridItemType.AlternatingItem Then
            Dim target As Control = e.Item.FindControl("targetControl")
            If Not [Object].Equals(target, Nothing) Then
                If Not [Object].Equals(Me.RadToolTipManager1, Nothing) Then
                    'Add the button (target) id to the tooltip manager
 
                    Me.RadToolTipManager1.TargetControls.Add(target.ClientID, (TryCast(e.Item, GridDataItem)).GetDataKeyValue("ProductID").ToString(), True)
                End If
            End If
        End If
    End Sub
    Protected Sub RadGrid1_ItemCommand(source As Object, e As GridCommandEventArgs)
        If e.CommandName = "Sort" OrElse e.CommandName = "Page" Then
            RadToolTipManager1.TargetControls.Clear()
        End If
 
    End Sub
 
End Class




2 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 29 Aug 2012, 10:47 AM
Hello Tomica,

Indeed you are correct that the VB code of this example is not very accurate. Actually the problem is that in the VB page the CS version of the user control is registered.  I have updated it accordingly and the next upload of the demos will reflect the change.

Meanwhile you can apply the following modifications to the original code:

  1. DefaultVB.aspx -> the registration of the user control should read:
    <%@ Register Src="ProductDetailsVB.ascx" TagName="ProductDetails" TagPrefix="uc1" %>


  2. DefaultVB.aspx.vb -> in the UpdateToolTip method change the following lines as specified bellow:
    ...
    Dim ctrl As Control = Page.LoadControl("ProductDetailsVB.ascx")
    ...
    Dim details As ProductDetailsVB = DirectCast(ctrl, ProductDetailsVB)

I hope this helps.

Kind regards,
Martin
the Telerik team

If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Tomica
Top achievements
Rank 2
answered on 29 Aug 2012, 05:09 PM
Thank you, I see that my error was in stripping-out too much from the top of the page.

In my alternate test, I had dragged the control and VS2010 had done the registration for me.

All is working well, and my client is very impressed!
Tags
Grid
Asked by
Tomica
Top achievements
Rank 2
Answers by
Martin
Telerik team
Tomica
Top achievements
Rank 2
Share this question
or