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

custom usercontrol inside of radtooltip using manager not persisting values

6 Answers 314 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
SelAromDotNet
Top achievements
Rank 2
SelAromDotNet asked on 25 Sep 2008, 04:11 PM
I did a few searches here but didn't find anything that matches exactly what I'm trying to do, so I hope someone can help me.

I'm wanting to create a tooltip that has a loadondemand user control which allows users to perform a quick search. the user control has a multiview with the first view being the search form, and the second view being the results.

the tooltip loads up the control just fine, but when I submit the search form, it clears it out and submits as if it was empty, telling me that I submitted a blank form. it appears that the values I submit are not being persisted during the ajax postback. how do I fix this?

I tried switching to a regular tooltip (in the scenario above I'm using the tooltipmanagers onajaxupdate to load the control) and it SORT of worked, but if I submit a search, close the tooltip, refresh the page, then do another search, I get viewstate errors because the usercontrol is physically rendered on the page instead of being loaded on demand.

I also tried putting the ajaxupdatepanel as a wrapper to the tooltip and the tooltipmanager. I tried the updatepanel inside the user control and I even tried adding the panel at runtime, then adding the control to the panel. that also doesn't work...

here's some of the code I'm using now:

protected void RadToolTipManager1_AjaxUpdate(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs e)  
{  
    Control ctrl = Page.LoadControl("~/search.ascx");  
    Telerik.Web.UI.RadAjaxPanel pnl = new Telerik.Web.UI.RadAjaxPanel();  
    pnl.Width = new Unit(500);  
    pnl.Controls.Add(ctrl);  
    e.UpdatePanel.ContentTemplateContainer.Controls.Add(pnl);  

what is the correct way to load a usercontrol on demand?

I also tried the radwindow but of course that can't load a usercontrol (ascx) and making a whole page seems like an inefficient approach...

hope that was detailed enough, let me know if you need more information. many thanks!

6 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 26 Sep 2008, 10:10 AM
Hello SelArom,

In the provided code snippet I do not see where you pass an argument to your user control in order to determine how to populate it. Please, note that in our LoadOnDemand demo we have implemented a public property in the user control which determines how to populate it and we set the appropriate value to it in the OnAjaxUpdate event:

            Control ctrl = Page.LoadControl("ProductDetails.ascx");  
            panel.ContentTemplateContainer.Controls.Add(ctrl);  
            ProductDetails details = (ProductDetails)ctrl;  
            details.ProductID = elementID;   
 

I believe that examining the full source code of the demo, including the user control, will clear the situation and that is why I want to remind you that when you install RadControls, our online examples projects are automatically installed on your computer and you can not only examine their full source code, but also extend them further in order to meet your requirements.

You can open the demos from here:

Start\Programs\Telerik\RadControls for ASPNET AJAX\Open Sample WebSite In VisualStudio

The actual location on your hard disk is the following one:

C:\Program Files\Telerik\RadControls for ASPNET AJAX Q1 2008\Live Demos

I hope that this information is helpful.

Regards,
Svetlina
the Telerik team


Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
SelAromDotNet
Top achievements
Rank 2
answered on 26 Sep 2008, 02:05 PM
thank you for your reply. the usercontrol I am using is not populated with any information. it is simply a form that the USER will populate with information. there is a radiobuttonlist and a textbox. the radiobutton list allows them to choose the type of search, the textbox is to collect their search terms...

after they enter their search terms they click submit and the control should run the search. unfortunately when they click search, it erases everything they submitted and says that they submitted an empty query.

i am using sitefinity so I do not have the examples to which you are referring. I'm hoping to purchase them before the end of this month, fingers crossed....

but why is the information that is submitted into the form on the usercontrol not being saved between postbacks?

thanks
0
Svetlina Anati
Telerik team
answered on 30 Sep 2008, 08:39 AM
Hi SelArom,

Basically, the RadToolTipManager adds an update panel when its OnAjaxUpdate event is set - this being said, it behaves as such. I am not quite sure about your exact setup and I prepared and attached a sample test project which demonstrates the functionality you described. What I can assume for your case is that the update panel is updated before you extract the values.

Would you please test your scenario by replacing the tooltip with a standard update panel and test whether the project behaves as expected? In case you make it work correctly with the update panel and not with the RadToolTipManager, please provide a sample demo with the update panel and I will make the RadToolTipManager replicate the same logic. 

Best wishes,
Svetlina
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
SelAromDotNet
Top achievements
Rank 2
answered on 30 Sep 2008, 05:35 PM
I ended up using the radwindow and a full custom page instead. In the end it worked out better, though if I encounter this problem again I'll be sure and update here. Thanks again for your help.
0
Zinoviy Margovskiy
Top achievements
Rank 1
answered on 05 Jun 2009, 09:01 PM
Hi,

I have similar scenario but different question. 
Basically, I have a user control which I load on "OnAjaxUpdate" event. This control
receives search criteria from parent page/control and does the search.  The results displayed inside repeater within this control.

Now, users can select a repeater row from search results by clicking "select" action on repeater. Once they select the row, my parent control/page needs to receive selected data.

In summary, I guess I am asking, how can I pass value(s) from a control inside tooltip back to parent control?



0
Svetlina Anati
Telerik team
answered on 11 Jun 2009, 08:49 AM
Hi Zinoviy,

As far as I understand form your explanations you are using a RadToolTipManager to load a user control on demand by using AJAX and you want to pass some parameter from the user control to the parent page. If so, please note, that this can be done in every manner you do this when dealing with a dynamically loaded user control in an update panel because this is exactly what the used functionality offers. This being said, you can use different techniques - implement and assign a public property which will hold the parameter value, directly call a method from the parent page in the user control and pass the parameter as an argument to this method, use the Session object and set the parameter there in order to read it in the main page, etc. Please, examine the techniques, which are used when passing parameters from a user control to the main page and choose the one which best meets your exact requirements and scenario.

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.
Tags
ToolTip
Asked by
SelAromDotNet
Top achievements
Rank 2
Answers by
Svetlina Anati
Telerik team
SelAromDotNet
Top achievements
Rank 2
Zinoviy Margovskiy
Top achievements
Rank 1
Share this question
or