Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesViewstateViewstate
Previous
 
Next
New Post
1/20/2011 1:59 AM
 
Hello,

I'm having issues with the viewstate. In my master control I dynamically load either a master or detail sub-control in the page_Init. The detail page has a treeview control and then uses a multi-view control to display the panel associated with the depth of he node selected on the tree. On the panel being displayed I have a cascading ddl which initiates a postback. When it does, the viewstate is not maintained. Any ideas as to why?

Thanks in Advance,
Chad
 
New Post
1/20/2011 11:01 AM
 
you have to take extra steps with dynamic controls - http://www.4guysfromrolla.com/articles/092904-1.aspx

Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
1/20/2011 12:38 PM
 
Thanks Cathal for the link. It helped me understand the page process flow and why controls need to be added in the Init phase. However, that is where I am loading the controls, but viewstate still is not persisting. Here are some code snippets.

As an overview of what I've got:
1. LoadControl.ascx - based on reading query string parameters, determines whether to load the master or the detail .ascx.
2. Master.ascx
3. Detail.ascx

Here is the applicable code in LoadControl.ascx:
01.Inherits Entities.Modules.PortalModuleBase
02. 
03.    Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
04.        Call LoadDynamicControl()
05. 
06.    End Sub
07.Public Sub LoadDynamicControl()
08.        Dim controlToLoad As Control
09. 
10.        Try
11.    
12.            Dim intID As Integer = Convert.ToInt32(Request.QueryString("ID")) 'A dyno link was clicked
13. 
14.            If intID > 0 Then
15.                controlToLoad = Me.LoadControl("Controls/Details.ascx")
16.            Else
17.                controlToLoad = Me.LoadControl("Controls/Master.ascx")
18.            End If
19. 
20.            Me.Controls.Add(controlToLoad)
21.            phViewControl.Controls.Add(controlToLoad)
22. 
23.        Catch exc As Exception        'Module failed to load
24.            ProcessModuleLoadException(Me, exc)
25.        End Try
26.    End Sub

On the Detail.ascx page, a panel is displayed with a detailview control that has a cascading ddl. When you change the parent ddl, a postback is initiated to set the value of the dependent ddl. However, when the page comes back from the postback, the parent ddl has gone back to its default selection and the child ddl is set to it's default selection. 

As I am loading the control in the Init phase, how come viewstate is not being maintained?

Thanks,
Chad
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesViewstateViewstate


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out