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.0Extending core modulesExtending core modules
Previous
 
Next
New Post
3/9/2007 8:30 AM
 
Hello!

I am searching for a way to extend core modules (in my case the link module) without changing the code - I would like to use this method with other modules too so I posted here. My idea is this:
I create a custom module which should use the link module, but it should change the way links are displayed. All I do is to copy the dnn_links.dnn for my module and change it from:
<control>
  <src>DesktopModules/Links/Links.ascx</src>
  <type>View</type>
  <helpurl>http://www.dotnetnuke.com/default.aspx?tabid=787</helpurl>
</control>

to

<control>
  <src>DesktopModules/MyCustomizedLinks/MyLinks.ascx</src>
  <type>View</type>
  <helpurl>http://www.dotnetnuke.com/default.aspx?tabid=787</helpurl>
</control>

Then in MyLinks.ascx.cs in the OnInit function I do this:
.....             
    Control ctrl = LoadControl("../../DesktopModules/Links/Links.ascx");
    objModule = (DotNetNuke.Modules.Links.Links)ctrl;
    if (objModule != null)
    {
        Controls.Add(objModule);
        objModule.ModuleConfiguration = ModuleConfiguration;
    }
....

It works - my module uses the link module.

BUT: I want to EXTEND the core Links.ascx.cs
So I tried this way:
I created I file called MyDerivedLinks.ascx.cs (with appropriate class) which inherits from DotNetNuke.Modules.Links.Links - there I could override a public function

Now I change MyLinks.ascx.cs to:#
.....             
    Control ctrl = LoadControl("../../DesktopModules/Links/Links.ascx");
    objModule = (MyCustomizedLinks.MyDerivedLinks)ctrl;
    if (objModule != null)
    {
        Controls.Add(objModule);
        objModule.ModuleConfiguration = ModuleConfiguration;
    }
....

And there comes my problem:

Error:
DotNetNuke.Services.Exceptions.ModuleLoadException: Unable to cast object of type 'ASP.desktopmodules_links_links_ascx' to type 'MyCustomizedLinks.MyDerivedLinks'.

Thank you!
Torres
 
New Post
3/12/2007 4:30 AM
 
Problem solved.
Thank you.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Extending core modulesExtending core modules


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