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.0Dynamic User Controls and Parameter ValuesDynamic User Controls and Parameter Values
Previous
 
Next
New Post
5/14/2007 7:01 PM
 
Hi,
 

Thanks for the excellent help you guys gave me on adding dynamic user controls using LoadControl.

Now I have a question about the dynamic loading of a user control and then passing values to other controls contained in the user control. I am dynamically loading a user control that has a repeater. The repeater is loaded with an ObjectDataSource. I actually got it to work. However it seems, well, a little kludgy to me. Note that in the code below I used the DefaultValue property because I could not figure out what the property for the “regular” value was or how to access it. If any one knows how to do this I would certainly appreciate being enlightened. Here is the code I used.

        Private Sub LoadNewCtl(ByVal pMbrId As String)

 

            ' This creates the ascx control virtual path

Dim DynPg As String = DotNetNuke.Common.ResolveUrl(Me.TemplateSourceDirectory & "/DocsList.ascx")

 

' This creates the user control with the LoadControl method

Dim objModule As Entities.Modules.PortalModuleBase = CType(Me.LoadControl(DynPg), Entities.Modules.PortalModuleBase)

 

            ' This sets the default value of the ObjectDataSource

Dim objDatSrc As ObjectDataSource = objModule.FindControl("ObjectDataSrcDoc")

 

objDatSrc.SelectParameters.Item("MbrId").DefaultValue = pMbrId

 

            ' This adds the user control to the control collection of

            ' a place holder.

            If Not objModule Is Nothing Then

                MbrGridView.Visible = False

                objModule.ModuleConfiguration = Me.ModuleConfiguration

                phDynPlaceHld.Controls.Add(objModule)

            End If

 

        End Sub

 

 
New Post
5/14/2007 9:01 PM
 

You might want to take a look at this:

DynamicForms

When you load a ASP.NET control dynamically and then click the submit button on the main page (causing a postback), the dynamically loaded control disappears and you lose all the information :) So I have to always use the Dynamic Placeholder from Denis Bauer

As far as DefaultValue = pMbrId. This is what I have been using and it works fine. If anyone else has a better way I would like to hear it too, but I don't see any other choice when you're outside of the normal ObjectDataSource "selecting event". For example:

at: http://www.adefwebserver.com/DotNetNukeHELP/DNN_Things4Sale/ThingsForSale3.htm

I have:

 

Protected Sub SetModuleId(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles ObjectDataSource_ThingsForSale.Selecting

e.InputParameters("ModuleId") = ModuleId.ToString

End Sub

This doesn't work if you're trying to set the parameter outside of the event.



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
5/14/2007 10:27 PM
 
Thanks for the reply Michael. The links were very helpful and I did download Denis’ Dynamic Placeholder. It will obviously be useful and save some angst.
 
BTW, I posted this question on the ASP.NET forum so if I get any words of wisdom from that I’ll post the answer here. I did think of one possible alternative to the DefaultValue albeit very indirect. I think you can set up a user defined property in a user control and set it with a value. You could then probably use that value in the ObjectDataSource selecting event. If I get around to it I might try it just for drill but I like direct approaches. I have to believe this “feature” for the ObjectDataSource control is an oversight.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Dynamic User Controls and Parameter ValuesDynamic User Controls and Parameter Values


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