Wednesday, February 25, 2009

How to use DotNetNuke Module Control in WebParts

Some days ago i was working on an assignment and was wondering how we can use a DotNetNuke module control in Web Part control. I developed a dotnetnuke module's view type of control which shows top 10 guest book comments and its working properly in dotnetnuke. Now the questions is, how can I use the same control in webparts framework also?

Well I've started some research and started with some basics. DotNetNuke module controls are inherited from DotNetNuke.Entities.Modules.PortalModuleBase. They can then import various DotNetNuke interfaces for plugable features like IActionable, IModuleListener, IModuleCommunicator etc. To use a control as a webpart control, it must inherit IWebPart interface and implement it. So I just do that:

#region IWebPart Members
private string _ImageUrl;
private string _title;
private string _description;
private string _subtitle;
private string _titleIconImageUrl;
private string _titleUrl;
public string CatalogIconImageUrl
{
get
{
return _ImageUrl;
}
set
{
_ImageUrl = value;
}
}

public string Description
{
get
{
return _description;
}
set
{
_description = value;
}
}

public string Subtitle
{
get { return _subtitle; }
}

public string Title
{
get
{
return _title;
}
set
{
_title = value;
}
}

public string TitleIconImageUrl
{
get
{
return _titleIconImageUrl;
}
set
{
_titleIconImageUrl = value;
}
}

public string TitleUrl
{
get
{
return _titleUrl;
}
set
{
_titleUrl = value;
}
}

#endregion

After that, I started using it on my webpart's page. I just register that control and use it under CatalogZone control's WebPartTemplate.

My module is working well as well as my webpart control is also working cool. Anybody who want to do this can simply learn the basics for implementing webparts, and for that, just go through the walkthroughs of msdn for webparts and then try my trick.

2 comments:

  1. Thanks. This was very helpful!

    ReplyDelete
  2. Thanks a ton it has been a good guide, now to use dotnetnuke module control in we is without a doubt very easy utilizing your information. Thanks

    ReplyDelete

Please add your valuable comments about this post if it helped you. Thanks

Popular Posts