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

Passing productid to the usercontrol

3 Answers 69 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Nik
Top achievements
Rank 1
Nik asked on 28 Sep 2009, 07:44 PM
I'm having a hard time understanding the demo of Load on Demand (http://demos.telerik.com/aspnet-ajax/tooltip/examples/loadondemand/defaultVB.aspx). 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

3 Answers, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 01 Oct 2009, 02:31 PM
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,
Tsvetie
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
Nik
Top achievements
Rank 1
answered on 01 Oct 2009, 07:50 PM
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"
      <controls> 
            <add tagPrefix="ucQuickPeek" src="~/includes/userctrl/ucQuickPeek.ascx" tagName="QuickPeek"/> 
      </controls> 
</pages> 

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"
panel.ContentTemplateContainer.Controls.Add(ctrl) 
'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.
0
Nik
Top achievements
Rank 1
answered on 05 Oct 2009, 02:56 PM
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!



Tags
ToolTip
Asked by
Nik
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Nik
Top achievements
Rank 1
Share this question
or