how dnn loads user controls dynamically?
Last Post 04/09/2009 6:23 AM by sacho. 9 Replies.
Author Messages
sacho
Nuke Newbie
Nuke Newbie
Posts:7


--
04/01/2009 1:47 AM  
i just started work on dnn and got confused how user controls are dynamically get loaded in default.aspx? i debugged the source but that looks quite complicated to understand the flow. please help me in understanding the process flow of dnn or is there any document available which will explain the process of loading dynamically user controls and skins in dnn? also from web i found some concept related to skin please let me know if i m wrong? - skin contains files like htm or xml which contains tokens in it. these tokens get replaced by user controls at run time (?) - so while creating module, should i need to create different user controls which contains token related to each in skin files? then how would i(or is it inbuilt process?) dynamically load that usercontrol in place of token? is there any sample module or article which explains how to apply skin in module? any help will be appriciated.
Joseph Craig
DNN MVP
Posts:11667


--
04/01/2009 8:50 AM  
I recommend two books: Professional DotNetNuke 5.0 & DotNetNuke Module Programming.

I also recommend Michael Washington's adefwebserver.com site.



Joe Craig, Patapsco Research Group
Complete DNN Support
sacho
Nuke Newbie
Nuke Newbie
Posts:7


--
04/01/2009 10:59 AM  
thank you for your reply. i checked the Michael Washington's articles and were able to create module successfully but i didnt get how to achieve following thing, "on module i have one button which i need to hide/display using skin/template by registered user." should i need to create user control for button and in skin provide token for this user control. if yes i m not getting how to relate this technically
Joseph Craig
DNN MVP
Posts:11667


--
04/02/2009 10:48 AM  
Within the module you can check the user's status. That is, you can determine if the user is in the "registered user" role.

If this is a button that will ALWAYS be shown to registered users but not shown to others, you use the visibility attribute of the button, setting it depending on the user.

Joe Craig, Patapsco Research Group
Complete DNN Support
sacho
Nuke Newbie
Nuke Newbie
Posts:7


--
04/06/2009 7:53 AM  
that can be done but can i decide it using template and how? like create token for button. if token present (or placed at specific location then btn moves at that palce) in template file then display button if not present then do not display it. Is this approach used in dnn? am i on right track? i chked one of "forum" module (active forum) which provides document, explaining template structure and using this user can decide whole layout. so i need to do something like same.

Joseph Craig
DNN MVP
Posts:11667


--
04/06/2009 7:57 AM  
ActiveForums does have a templating system, but that is only for the Active Forums module.

My reply address placing a button in a custom module.  You can also conditionally have items appear or not appear in a skin file.

Perhaps if you explain in more detail what you are trying to do, then the answer will be more specific.

Joe Craig, Patapsco Research Group
Complete DNN Support
sacho
Nuke Newbie
Nuke Newbie
Posts:7


--
04/06/2009 10:24 AM  
thanks for your reply. my main aim is only to know how to achieve dynamic layout using template? as you mentioned in reply that items appear/not appear in a skin file same like active forum. if for button it worked then i can build my module accordingly.

if there are any sample/document on how to do it then that would be helpful.
Joseph Craig
DNN MVP
Posts:11667


--
04/06/2009 12:43 PM  
The book and website references I mentioned earlier in this thread are the best resources for module development.

Joe Craig, Patapsco Research Group
Complete DNN Support
Scriptmonkey
Posts:10


--
04/06/2009 3:04 PM  
Hi Sacho,

There's definitely value to understanding how DNN dynamically loads User Controls, but it may be more involved than you need for what you are trying to accomplish.  ...For your immediate task, you may want to check out Open-SmartModule.  It's a $28 module wrapper that lets you use non-DNN ASP.NET User Controls in DotNetNuke.  Using that type of thing you could query Security Roles, and make a button Visible=False like any other ASP.NET program.  ...This is all at a User Control level.  Skins really don't contain logic to hide or show buttons and controls.  Here's the link to them...

http://www.opendnn.com/DNNModules/O...fault.aspx

For more understanding on how DNN, and ASP.NET in general uses Dynamically generated User Controls, you might want to check out some of the following links.

http://odetocode.com/Blogs/scott/ar.../5365.aspx
http://aspnet.4guysfromrolla.com/ar...402-1.aspx
http://www.brettb.com/DynamicUserCo...ontrol.asp

Dynamic Controls are something that ASP.NET is generally bad at.  A dynamically loaded control must be recreated using code each time a Page Loads or Posts back.  It can only be recreated at a particular point in a particular order in the Page Life Cycle.  There's a Control Tree order that must be maintained so Controls nested inside other controls don't get created before their parent controls do.

It's a complicated topic, and one can live a long and fulfilling life without knowing anything about it.  But if you've got the itch, check out some of the links.

sacho
Nuke Newbie
Nuke Newbie
Posts:7


--
04/09/2009 6:23 AM  

thanks for your replies. now i have below issue with dnn stylesheet.

1.   i created new module and added module.css file in new module this css file applies to module successfully when placed in module (not in any folder under module), but when i created new folder call styles and cut paste module.css file to this folder folder i found that style was not get applied to module. even when reference to the file specified it wont worked. am i missing anything here?

<link id="Link1" href="Skin/module.css" enableviewstate="true" runat="server" type="text/css" rel="Stylesheet" />

while developement vs provided list of files for href attribute. i selected module.css here like shown above.
even tried with diff href values like ./skin/module.css but no luck

2. is the css name (module.css) matters here? if i changed the file name to some different name will that affect?

any help would be appriciated. thanks!



---