Friday, 14 June 2013 13:55

how to check if multiple same modules are in the page in dotnetnuke

Written by 
Rate this item
(0 votes)

sometimes it's needed to check whether there are multiple same
modules in the current page or not to keep one version of the
module or some other checks.

these codes helps to achieve the above checks -

ModuleController controller2 = new ModuleController();

int num = 0;
ModuleInfo module = controller2.GetModule(base.ModuleId, base.TabId);//get current module

foreach (KeyValuePair<int, ModuleInfo> pair in controller2.GetTabModules(base.TabId))
{
if (!pair.Value.IsDeleted && (pair.Value.ModuleDefID == module.ModuleDefID))
{
num++;
}
}

if num value is over 1 then there are multiple same modules exist in the current
page(tab).

if that helped don't forget to +1 this in google search.

Read 1104 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
Login to post comments