Passing productid to the usercontrol

4 posts, 0 answers
  1. Nik
    Nik avatar
    51 posts
    Member since:
    Sep 2009

    Posted 28 Sep 2009 Link to this post

    I'm having a hard time understanding the demo of Load on Demand ( Primarily, how the productid is passed into the UC. I see it on the manager.targetcontrols.add line in defaultvb.aspx.vb, but I'm failing to see how the UC gets that value. Is it the last 2 lines in UpdateToolTip sub? What is the function of those lines? If you could explain the process a little bit, it would be greatly appreciated!

    Also, can you pass more than 1 thing from the tooltip into the UC?

    Using version 2008.1.515.20
  2. Tsvetie
    Tsvetie avatar
    1517 posts

    Posted 01 Oct 2009 Link to this post

    Hi Nik,
    Yes, the last two lines in the UpdateToolTip method do the trick:
    Dim details As ProductDetails = DirectCast(ctrl, ProductDetails) 
    details.ProductID = elementID 

    The ProductDetails UserControl has a ProductID property that we set to the Value passed to the RadToolTipManager for the TargetControl. Here is the code that sets this Value:
    Me.RadToolTipManager1.TargetControls.Add(image.ClientID, currentRow.Row("ProductID").ToString()True

    , and here is the code that gets this Value is the AjaxUpdate handler:
    Protected Sub OnAjaxUpdate(ByVal sender As ObjectByVal args As ToolTipUpdateEventArgs) 
        Me.UpdateToolTip(args.Value, args.UpdatePanel) 
    End Sub 

    You can only use the Value for the TargetControl to pass an argument to the AjaxUpdate handler. That is why, in case you want to pass two values, you should combine them using a delimiter and set the result as Value. After that, in the AjaxUpdate handler, you can get the two values by splitting the args.Value using the same delimiter.

    Kind regards,
    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.
  3. Nik
    Nik avatar
    51 posts
    Member since:
    Sep 2009

    Posted 01 Oct 2009 Link to this post

    In your example code that I am following, the tag for the user control is set up on the page using the register tag, I have my user controls referenced within the web config file like so.

    <pages enableViewStateMac="false"
                <add tagPrefix="ucQuickPeek" src="~/includes/userctrl/ucQuickPeek.ascx" tagName="QuickPeek"/> 

    So the line that you called out doesn't allow me to cast the variable details as my user control, which in this case is called ucQuickPeek.
    'These two lines work 
    Dim ctrl As Control = Page.LoadControl("/includes/userctrl/ucQuickPeek.ascx"
    'Line below is what is blowing up 
    Dim details As ucQuickPeek = DirectCast(ctrl, ucquickpeek) 
    'Error message: Type 'ucQuickPeek' is not defined 

    The piece after the "As" is blowing up on me and not sure why that is the case. I tried placing the user control onto the page, and still got the same result.
  4. Nik
    Nik avatar
    51 posts
    Member since:
    Sep 2009

    Posted 05 Oct 2009 Link to this post

    We've since tried adding:
    <ucQuickPeek:QuickPeek runat="Server" ID="ucQuickPeek"  />
    to the bottom of the index page that has the tooltip/tooltipmanager. We've also tried adding:
    <%@ Register Src="~/includes/userctrl/ucQuickPeek.ascx" TagName="QuickPeek" TagPrefix="uc1" %>
    to the top of the same page. All with no luck. The directcast line refuses to see the quickpeek usercontrol type.

    I would love to compile a sample solution for you, but that simply isn't possible with the size and scope of this project, as well as all of the database connections this piece has. I will be happy to include any more bits of relevant code if needed. Any additional help on this would be greatly appreciated, as the deadline for this is drawing near!

Back to Top