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/3/2007 8:13 AM
 

I have an example here;

DynamicForms



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
7/3/2007 8:21 AM
 

Basically uses code such as this

 

colControlCollection = CType(DynamicPlaceHolder.FindControl("DynamicPage"), Entities.Modules.PortalModuleBase).Controls
            For Each Item In colControlCollection
                tmpType = Item.GetType().FullName
 
                objItemType.RecordID = CInt(CurrentRecord.Text)
                objItemType.FormID = CInt(ddlControl.SelectedValue)
 
                Select Case Item.GetType().FullName
                    Case "System.Web.UI.WebControls.TextBox"
                        tempTextBox = CType(Item, TextBox)
                        objItemType.ItemTypeName = "TextBox"
                        objItemType.ItemName = tempTextBox.ID
                        objItemType.ItemValue = tempTextBox.Text
                        If tempTextBox.Rows > 1 Then
                            objItemType.LargeText = True
                        End If
                    Case "System.Web.UI.WebControls.DropDownList"
                        tempDropDownList = CType(Item, DropDownList)
                        objItemType.ItemTypeName = "DropDownList"
                        objItemType.ItemName = tempDropDownList.ID
                        objItemType.ItemValue = tempDropDownList.SelectedValue
                    Case "System.Web.UI.WebControls.ListBox"
                        tempListBox = CType(Item, ListBox)
                        objItemType.ItemTypeName = "ListBox"
                        objItemType.ItemName = tempListBox.ID
                        objItemType.ItemValue = tempListBox.SelectedValue
                    Case "System.Web.UI.WebControls.CheckBox"
                        tempCheckBox = CType(Item, CheckBox)
                        objItemType.ItemTypeName = "CheckBox"
                        objItemType.ItemName = tempCheckBox.ID
                        objItemType.ItemValue = tempCheckBox.Checked
                    Case "System.Web.UI.WebControls.CheckBoxList"
                        tempCheckBoxList = CType(Item, CheckBoxList)
                        objItemType.ItemTypeName = "CheckBoxList"
                        objItemType.ItemName = tempCheckBoxList.ID
 
                        Dim strSelectedItem As String = ""
                        Dim objListItemCollection As ListItemCollection = tempCheckBoxList.Items
                        Dim objListItem As ListItem
                        For Each objListItem In objListItemCollection
                            If objListItem.Selected Then
                                strSelectedItem += objListItem.Value.Replace(",", "") & ","
                            End If
                        Next
 
                        If strSelectedItem <> "" Then
                            strSelectedItem = strSelectedItem.Substring(0, (strSelectedItem.Length - 1))
                        End If
 
                        objItemType.ItemValue = strSelectedItem
                    Case "System.Web.UI.WebControls.RadioButton"
                        tempRadioButton = CType(Item, RadioButton)
                        objItemType.ItemTypeName = "RadioButton"
                        objItemType.ItemName = tempRadioButton.ID
                        objItemType.ItemValue = tempRadioButton.Checked
                    Case "System.Web.UI.WebControls.RadioButtonList"
                        tempRadioButtonList = CType(Item, RadioButtonList)
                        objItemType.ItemTypeName = "RadioButtonList"
                        objItemType.ItemName = tempRadioButtonList.ID
                        objItemType.ItemValue = tempRadioButtonList.SelectedValue
                    Case Else
                        objItemType.RecordID = -1
                End Select
 
                ' If we have a value then save it
                If objItemType.RecordID > 0 Then
                    DynamicForms_DAL.AddRecordData(objItemType)
                    DynamicForms_DAL.AddFormData(objItemType)
                End If
 
            Next


Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
7/6/2007 3:44 AM
 

Michael - actually i found the best solution for me and you might look at it

http://msdn2.microsoft.com/en-us/library/aa479330(d=printer).aspx

using the interface saves me from having to use reflection and the overhead of that but better than that it ensures my controls all have the same properties for use in the module


Dylan Barber http://www.braindice.com - Dotnetnuke development classes - skins and modules
 
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