DotNetNuke – Modules – Linking within the module

OLYMPUS DIGITAL CAMERA         Now that we have the module skeleton up and running and we have a data access layer, the next thing we need to look at is specific functions you may need to use from within your code. One of the most useful functions is Globals.NavigateURL(). This is particularly useful if you want to generate a hyperlink back to the same page you are on. But with some additional code that we’ll introduce later, you can also use this to generate a hyperlink to another page.

Globals.NavigateURL() is located in the DotNetNuke.Common namespace. You’ll need to make sure that namespace is in whatever class you call this function from. Globals is the class name and NavigateURL is a static method with ten different overloads.

NavigateURL()
This simply provides a URL back to the page you are on. This is typically used from the Edit controls so that you can link back to the view that the edit control was originally on.

NavigateURL(int TabID)
This generates the URL to the page specified by TabId. In the early days of DNN, a page was a Tab on the navigation. TabId has kind of stuck ever since.

NavigateURL(string ControlKey)
If you need to generate a URL back to a specific control in the module (Edit or some other custom key), you can use this to generate that URL.

NavigateURL(int TabID, bool IsSuperTab)
The IsSuperTab parameter adds the PortalID to the URL if it is set to true.

NavigateURL(int TabID, string ControlKey)
This should be obvious. It creates a URL that leads to the page represented by TabID and the control represented by ConrolKey.

NavigateURL(string ControlKey, params string[] AdditionalParameters)
Next to NavigateURL(int TabID), this is probably the most useful form of this method. If you need to pass parameters into the page you are calling, this is the method you need. Using this function, you can do something like this:

string[] items = {"itemid=24"};
Globals.NavigateURL("",items);

Which will call back to the page you are on with itemid=24 as the parameter/value.

You can also use:

NavigateURL(int TabID, string ControlKey, params string[] AdditionalParameters)
if you need to call another page with parameters.

The three other overloads are similar to what I’ve already shown. The only additional parameter you need to be aware of is PortalSettings which, as far as I know, is only used internally. Don’t worry about it.

 

Other post in DotNetNuke - Module Development

Related Post

Leave a Reply

Comment Policy:

  • You must verify your comment by responding to the automated email that is sent to your email address. Unverified comments will never show.Leave a good comment that adds to the conversation and I'll leave your link in.
  • Leave me pure spam and I'll delete it.
  • Leave a general comment and I'll remove the link but keep the comment.

Notify me of followup comments via e-mail

Bear