1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Best way to communicate between usercontrols

Best way to communicate between usercontrols

4 posts, 0 answered
  1. Tys
    Tys  avatar
    8 posts
    Registered:
    04 Mar 2009
    12 Nov 2009
    Link to this post
    Hi Everyone,

    I'm building some custom usercontrol in visual studio and i'm using them within sitefinity. 
    Everything works fine, the controls are registered in the web.config, a cms-user can drop them on the webpages and they function well. But now there is a situation where sometimes there are 2 user controls on a page. (one in the content area and one in the side column) And when a button is pressed in one controls and want to trigger a method in that other control. 
    Can anyone tell me how this should be done? 

    Regards, Tys 
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Nov 2009
    Link to this post
    Hi Tys ,

    When you press the button you can append some QueryStrings, Cookie or Session that the other control could see after the post back from the first control.

    All the best,
    Ivan Dimitrov
    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. Tys
    Tys  avatar
    8 posts
    Registered:
    04 Mar 2009
    12 Nov 2009
    Link to this post
    Hi Ivan,

    When doing that there is problem in the loading sequence of the controls. The usercontrol with the method that i want to trigger loads before the onclick of the button on the first usercontrol fires. 
    Now, i've worked around this by moving some logic that detects the change that the button has caused to the OnPreRender  of that usercontrol, because that fires later than the button click. So things are working, but isn't there a more elegant way to do this? 
    Regards, Tys


  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    13 Nov 2009
    Link to this post
    Hi Tys ,

    You might try with storing a value in the viewstate, but the point is that you will have to persist something, somewhere between the postbacks.

    Best wishes,
    Georgi
    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.
Register for webinar
4 posts, 0 answered