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

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Loading dynamic controls and getting info back from them (reflection?)Loading dynamic controls and getting info back from them (reflection?)
Previous
 
Next
New Post
7/2/2007 10:31 PM
 

I have a table that has the file name of the dynamic controls I am loading and I can load them just fine and all - not a problem

Now I am trying to save the info entered into these dynamic controls and not sure how really

They all expose a property called 'DefaultAnswer' that can get the value entered into the control but not sure how to be able to tell the page what the control has - i thought of reflection and think I have to use it in this case but not sure how

 

Anybody help me out on this one?

TIA


Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
New Post
7/2/2007 11:00 PM
 

well i hvae this for my datalist but i dont seem to get any answers back

 

Dim objCAP As New CAP_Controller
            For Each dlitem As DataListItem In lstContent.Items
                Dim aAnswer As CAP_AnswersInfo = New CAP_AnswersInfo
                With aAnswer
                    .QuestionID = lstContent.DataKeys(dlitem.ItemIndex)
                    Dim DynamicPlaceholder As New Panel
                    DynamicPlaceholder = CType(dlitem.FindControl("pnlDynamicLoad"), Panel)
                    ' Dim aControl As Control = CType(DynamicPlaceholder.Controls.Item(0).GetType, Control)
                    '.Answer = aControl.DefaultAnswer
                    Dim aControl As Control = CType(DynamicPlaceholder.Controls.Item(1), Control)
                    Dim aControlType As Type = aControl.GetType()
                    Dim myAnswer As PropertyInfo = aControlType.GetProperty("DefaultAnswer")
                    .Answer = myAnswer.GetValue(aControl, Nothing).ToString()
                End With
                'save our info to the table
                objCAP.RCIWebApps_CAP_SaveAnswer(aAnswer)

                'objCAP.RCIWebApps_CAP_UpdateAnswer(aAnswer)
            Next


Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
New Post
7/2/2007 11:20 PM
 

Have you put a break point in " aControlType.GetProperty" to ensure it is being hit and has a value?

The problem may lie in how/when the dynamic control is being loaded.  Dynamic controls need to be saved so they can be recreated in an overloaded LoadViewState sub.  If you're not already doing that I would search for a Dynamic Control Placeholder to do the dirty work for you.  I got this on a quick search - http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx 

 

 

 
New Post
7/3/2007 12:19 AM
 

Well i have and dont get and info out of it other than its default value - and if i just do a post back it loses its changed data of course

I actually tried the dynamic placeholder andit doesnt work

 

 


Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
New Post
7/3/2007 1:19 AM
 

Hmmm.  When you tried the dynamic placeholder, did you make sure your loadcontrol code was only fireing when Not IsPostback?   Maybe you're clearing and reloading the placeholder on postback?

I have never used a dynamic placeholder control (I probably would use one if I were starting out now) and my code is not encapsulated in an easily shareable manner and it only works for certain known control types.   But basically I -

Only create dynamic controls on an initialization event.

When created - save (I use an array in session) enough information about the control (ContainerID, ControlID, ControlType, etc) to re-create it and add it to its container.

Override LoadViewState in the containing control.  In this sub I call mybase.LoadViewState(savedState) - then recreate the dynamic controls with the saved info. 

 

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Loading dynamic controls and getting info back from them (reflection?)Loading dynamic controls and getting info back from them (reflection?)


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