0

I'm forming a newsletter with links to various html modules within my DNN website. I have access to each of their ModuleID's and I'm wanting to use that to get the url. The current approach (made by a third party developer) worked, but only to a degree. The url's are incorrectly formed when the Modules are located deeper in the website.

For example module located at www.website.com/website/articles.aspx is works fine, but a module located www.website.com/website/articles/subarticles.aspx won't. I know this is because the url is incorrectly formed.

Here's the current code:

DotNetNuke.Entities.Modules.ModuleController objModCtrlg = new DotNetNuke.Entities.Modules.ModuleController();
DotNetNuke.Entities.Modules.ModuleInfo dgfdgdg = objModCtrlg.GetModule(ContentMID);
TabController objtabctrll = new TabController();
TabInfo objtabinfoo = objtabctrll.GetTab(tabidfrcontent);
string tabnamefremail= objtabinfoo.TabName;
moduletitlefrEmail = dgfdgdg.ModuleTitle;
string readmorelinkpath = basePath + "/" + tabnamefremail + ".aspx";

ContentMID is the current module ID I'm looking at. I've tried to use Globals.NavigateURL, but that always crashes with Object reference not set to an instance of an object. error. Same thing when I use objtabinfoo.FullUrl so I'm currently at a loss as to how I get the specific modules URL.

EDIT: Here's some more code as to how the tabId is retrieved.

IDictionary<int, TabInfo> dicTabInfo12 = new Dictionary<int, TabInfo>();
ContentMID = Convert.ToInt32(dsNewsList.Tables[0].Rows[i]["ModuleID"]);
dicTabInfo12 = objTabctrl.GetTabsByModuleID(ContentMID);
if (dicTabInfo12.Count > 0)
{
    string tester = ""; //Debug
    foreach (KeyValuePair<int, TabInfo> item1 in dicTabInfo12)
    {
        tabidfrcontent = item1.Key;
    }
}
ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Mitchell
  • 253
  • 1
  • 5
  • 16

2 Answers2

1

You really should be using NavigateUrl to build the links ance if you have the tabid, you are golden.

string readMoreLinkPath = NavigateUrl(tabidfrcontent);

Nice and simple

Mitchel Sellers
  • 62,228
  • 14
  • 110
  • 173
  • I'm still getting the `Object reference not set to an instance of an object` Which I don't understand why. My only guess is that tabid is maybe wrong. Unfortunately I'm unable to properly debug so I'm relying on messages written out to a text file. – Mitchell Jul 13 '12 at 19:31
  • I just saw this post http://www.dotnetnuke.com/Resources/Forums/forumid/203/postid/361541/scope/posts.aspx I am using this in a scheduled task so that is probably why I'm getting the error. Question is, how am I going to get and assign the portal settings? – Mitchell Jul 13 '12 at 20:21
1

Okay, colleague suggested this and it works great within a scheduler.

string linkPath = basePath + "/Default.aspx?TabID=" + tabID;

Will Navigate you to the correct tab ID. So this would be the best solution if you're forced to work within a scheduler where you can't use NavigateUrl without some major workarounds.

Mitchell
  • 253
  • 1
  • 5
  • 16