Using ResolveUpdatedControls to optimize HTTP traffic

Thread is closed for posting
9 posts, 0 answers
  1. 5EBF5A6A-BC81-4048-A21D-DEF5EAD982C6
    5EBF5A6A-BC81-4048-A21D-DEF5EAD982C6 avatar
    19 posts
    Member since:
    Jul 2005

    Posted 22 Nov 2006 Link to this post

    Requirements

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

    .NET 2.0
    Visual Studio version

    VS 2005
    programming language

    C#
    browser support

    all browsers supported by r.a.d.controls


     
    PROJECT DESCRIPTION
    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. D9EDF5D1-57BE-4B80-A789-BCB74FBFB45C
    D9EDF5D1-57BE-4B80-A789-BCB74FBFB45C 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. D9EDF5D1-57BE-4B80-A789-BCB74FBFB45C
    D9EDF5D1-57BE-4B80-A789-BCB74FBFB45C 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 
            Get 
                '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 
            Get 
                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" 
                    Me.phParentGuardian.Controls.Add(myUserControl)  
                    If Not Session("FirstTimeParentGuardian"Is Nothing Then 
                        Session.Remove("FirstTimeParentGuardian")  
                    End If 
                      
     
                Case "ucFamilyMembers" 
                    uc = "~/controls/Journal/NewFamilyJournal_FamilyMembers.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucFamilyMembers" 
                    Me.phFamilyMembers.Controls.Add(myUserControl)  
     
                Case "ucOthersInHome" 
                    uc = "~/controls/Journal/NewFamilyJournal_OthersInHome.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucOthersInHome" 
                    Me.phOthersInHome.Controls.Add(myUserControl)  
     
     
                Case "ucPrimaryContact" 
                    uc = "~/controls/Journal/NewFamilyJournal_PrimaryContact.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucPrimaryContact" 
                    Me.phContact.Controls.Add(myUserControl)  
     
                Case "ucAdditionalContact" 
                    uc = "~/controls/Journal/NewFamilyJournal_AdditionalContact.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucAdditionalContact" 
                    Me.phAdditionalContact.Controls.Add(myUserControl)  
     
     
                Case "ucEmergencyContact" 
                    uc = "~/controls/Journal/NewFamilyJournal_EmergencyContact.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucEmergencyContact" 
                    Me.phEmergencyContact.Controls.Add(myUserControl)  
     
                Case "ucIncome" 
                    uc = "~/controls/Journal/NewFamilyJournal_Income.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucIncome" 
                    Me.phIncome.Controls.Add(myUserControl)  
     
                Case "ucSchool" 
                    uc = "~/controls/Journal/NewFamilyJournal_School_ChildCare.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucSchool" 
                    Me.phSchool.Controls.Add(myUserControl)  
     
                Case "ucComments" 
                    uc = "~/controls/Journal/NewFamilyJournal_Comments.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucComments" 
                    Me.phComments.Controls.Add(myUserControl)  
                     
                Case "ucAgency" 
                    uc = "~/controls/Journal/NewFamilyJournal_Agency.ascx" 
                    myUserControl = Page.LoadControl(uc)  
                    myUserControl.ID = "ucAgency" 
                    Me.phAgencyInformation.Controls.Add(myUserControl)  
     
            End Select 
        End Sub 'LoadUserControl 

    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
            Session("FirstTimePreview") = True 
            Me.LoadUserControl(Me.selectedUC)  
            If Not Page.IsPostBack Then 
                Session.Remove("SelectedPanelName")  
                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. FDC0E688-E31F-478A-84DA-597CB575F0B1
    FDC0E688-E31F-478A-84DA-597CB575F0B1 avatar
    1061 posts
    Member since:
    Sep 2012

    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. D9EDF5D1-57BE-4B80-A789-BCB74FBFB45C
    D9EDF5D1-57BE-4B80-A789-BCB74FBFB45C 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

    ViewState("selectedUC").ToString()

    and hence the error.

    Changed it to longer form

    Public Property selectedUC() As String 
            Get 
                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. 07F5E6D4-0AA5-456A-81A6-37DACDA77DBF
    07F5E6D4-0AA5-456A-81A6-37DACDA77DBF 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?

    thanks
  7. 6A71F205-2975-4A18-A08A-50D26BBE4E55
    6A71F205-2975-4A18-A08A-50D26BBE4E55 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.

    Thanks
  8. C7498A83-7E2E-418C-8791-93EF573A7569
    C7498A83-7E2E-418C-8791-93EF573A7569 avatar
    9934 posts
    Member since:
    Nov 2016

    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,
    Stephen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. B06B4673-5FBE-4ABB-94E8-814FADD37D00
    B06B4673-5FBE-4ABB-94E8-814FADD37D00 avatar
    6 posts
    Member since:
    Nov 2008

    Posted 29 Apr 2010 Link to this post

    HI,

    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,
    Victor
Back to Top

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