Using ResolveUpdatedControls to optimize HTTP traffic

Thread is closed for posting
9 posts, 0 answers
  1. Vladimir Milev
    Vladimir Milev avatar
    19 posts
    Member since:
    Jul 2005

    Posted 22 Nov 2006 Link to this post


    r.a.d.controls version r.a.d.controls Q3 2006
    .NET version

    .NET 2.0
    Visual Studio version

    VS 2005
    programming language

    browser support

    all browsers supported by r.a.d.controls

    Sometimes we need to have deeply nested controls that need to be updated only if some condition is met.  We may want to update the entire control subtree and replace it with something else, or we may want to update a single grandchild control that will display additional information to the user.  One can optimize the process and fine-tune the updates so that as little as possible gets updated.  To do that one should handle the ResolveUpdatedControls, and add controls to the e.UpdatedControls collection according to various criteria: previously fired postback events, ViewState values, Session parameters, URL query strings, etc.

    This example is a slightly modified version of this code library entry and it demonstrates how to use the ResolveUpdatedControls handler to apply fine-grained control over what to update and what not.
  2. Bryan Hughes
    Bryan Hughes avatar
    130 posts
    Member since:
    Oct 2005

    Posted 12 Apr 2007 Link to this post

    How would do this if the user control if it has a path like "~/controls/UserControls/MyControl.ascx"?
  3. Bryan Hughes
    Bryan Hughes avatar
    130 posts
    Member since:
    Oct 2005

    Posted 12 Apr 2007 Link to this post

    Trying to use your example but keep getting
    "Object reference not set to an instance of an object. "

    [NullReferenceException: Object reference not set to an instance of an object.]
       New_FamilyJournal.get_selectedUC() +71
       New_FamilyJournal.Page_Load(Object sender, EventArgs e) +61
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

    Here is code behind
     Public Property selectedUC() As String 
                'Keep last loaded user control in the View State  
                Return IIf(ViewState("selectedUC"Is Nothing"ucParentGuardian", ViewState("selectedUC").ToString())  
            End Get 
            Set(ByVal value As String)  
                ViewState("selectedUC") = value  
            End Set 
        End Property 

    Public Property selectedTab() As String 
                Return IIf(ViewState("selectedTab"Is Nothing"tbParentGuardian", ViewState("selectedTab").ToString())  
            End Get 
            Set(ByVal value As String)  
                ViewState("selectedTab") = value  
            End Set 
        End Property 

    Public Sub LoadUserControl(ByVal userControl As String)  
            Dim myUserControl As UserControl  
            Dim uc As String 
            Select Case userControl  
                Case "ucParentGuardian" 
                    uc = "~/controls/Journal/NewFamilyJournal_Parent_Guardian.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucParentGuardian" 
                    If Not Session("FirstTimeParentGuardian"Is Nothing Then 
                    End If 
                Case "ucFamilyMembers" 
                    uc = "~/controls/Journal/NewFamilyJournal_FamilyMembers.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucFamilyMembers" 
                Case "ucOthersInHome" 
                    uc = "~/controls/Journal/NewFamilyJournal_OthersInHome.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucOthersInHome" 
                Case "ucPrimaryContact" 
                    uc = "~/controls/Journal/NewFamilyJournal_PrimaryContact.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucPrimaryContact" 
                Case "ucAdditionalContact" 
                    uc = "~/controls/Journal/NewFamilyJournal_AdditionalContact.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucAdditionalContact" 
                Case "ucEmergencyContact" 
                    uc = "~/controls/Journal/NewFamilyJournal_EmergencyContact.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucEmergencyContact" 
                Case "ucIncome" 
                    uc = "~/controls/Journal/NewFamilyJournal_Income.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucIncome" 
                Case "ucSchool" 
                    uc = "~/controls/Journal/NewFamilyJournal_School_ChildCare.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucSchool" 
                Case "ucComments" 
                    uc = "~/controls/Journal/NewFamilyJournal_Comments.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucComments" 
                Case "ucAgency" 
                    uc = "~/controls/Journal/NewFamilyJournal_Agency.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucAgency" 
            End Select 
        End Sub 'LoadUserControl 

    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
            Session("FirstTimePreview") = True 
            If Not Page.IsPostBack Then 
                Dim FamilyJournal As Wish.BL.Wish.Entities.FamilyJournalJournals = New Wish.BL.Wish.Entities.FamilyJournalJournals()  
                Session("FamilyJournal") = FamilyJournal  
                Session("FirstTimeParentGuardian") = True 
                Session("FirstTimeFamilyMembers") = True 
                Session("FirstTimeOthersInHome") = True 
                Session("FirstTimePrimaryContact") = True 
                Session("FirstTimeAdditionalContact") = True 
                Session("FirstTimeEmergencyContact") = True 
                Session("FirstTimeIncome") = True 
                Session("FirstTimeSchool") = True 
                Session("FirstTimeComments") = True 
                Session("FirstTimeAgency") = True 
            End If 
        End Sub 

    What ami missing?
  4. Vladimir Milev
    Vladimir Milev avatar
    1061 posts

    Posted 13 Apr 2007 Link to this post

    Hi Bryan,

    We aren't exactly certain what the reason for your problem may be. I suggest that you open up a support ticket and send us your project so we can run and examine what's wrong.

    In general code library posts are open for questions regarding the posted code in the example and clarifications. We kindly suggest that customers open up support tickets when dealing with problems specific to their own implementations.

    Thanks for your understanding. I am looking forward to following up with you.

    All the best,
    Vladimir Milev
    the telerik team
  5. Bryan Hughes
    Bryan Hughes avatar
    130 posts
    Member since:
    Oct 2005

    Posted 13 Apr 2007 Link to this post

    I figured out my problem

    "IIF" is a built in function. So when you try to send expressions to it, they get evaluated before the function sees them.
    So in my case even if the Viewstate is empty it will try to evaluate


    and hence the error.

    Changed it to longer form

    Public Property selectedUC() As String 
                If ViewState("selectedUC"Is Nothing Then 
                    ViewState("selectedUC") = "ucParentGuardian" 
                End If 
                Return ViewState("selectedUC").ToString()  
            End Get 
            Set(ByVal value As String)  
                ViewState("selectedUC") = value  
            End Set 
        End Property 

    Works fine.
  6. James Wright
    James Wright avatar
    11 posts
    Member since:
    Mar 2006

    Posted 04 Jul 2007 Link to this post

    why do you post a .rar when every other example is .zip?

  7. Developer Developer
    Developer Developer avatar
    1 posts
    Member since:
    Sep 2005

    Posted 11 Sep 2007 Link to this post

    that is a good question why is the code posted as .rar when everything else seems to be in .zip couldn't consistency be maintained not everyone has winrar installed on their box can we get this changed please so that most everyone can download this.

  8. Sebastian
    Sebastian avatar
    9934 posts

    Posted 12 Sep 2007 Link to this post

    Hi Developer,

    You brought a valid point here and I converted the archive to zip format in order to extract it and take advantage of the technique presented in this code library thread. I should inform you that we provide only zip archives from some time ago due to the reason you mentioned here.

    Best regards,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. Victor
    Victor avatar
    6 posts
    Member since:
    Nov 2008

    Posted 29 Apr 2010 Link to this post


    Does this method still apply to the builds from 2009 or later? It seems the ResolveUpdatedControls event does not exist anymore. How can I achieve the same effect with the latest builds?

    Thank you,
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.