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.0get error when get portalID. Please helpget error when get portalID. Please help
Previous
 
Next
New Post
1/11/2009 1:02 PM
 

Hi everyone,

I create a new file aspx and when i try to get PortalID or PortalName i got error.

 <%@ Page Language="VB" %>

...

Response.Write(PortalSettings.Current.PortalId)

System.NullReferenceException: Object reference not set to an instance of an object. at ASP.objects_login_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in ...

I also try another way but got same error.

Dim ps As DotNetNuke.Entities.Portals.PortalSettings = PortalController.GetCurrentPortalSettings

response.write(ps.PortalId)

So I miss something? Please help

Thank you,

Best regard,

 
New Post
1/12/2009 10:35 AM
 

Hello Alfie,

When you call an external file from your skin file, the file has to be ".ascx" (not aspx).  Also, you can't have <%@ Page Language="VB" %> line on the external file. It'll break the skin. Don't ask me why. Something to do with... something lol. It's DNN Skin rule (or not..).

You can do following alternative way (Javascript):

1. Place <%@ Register TagPrefix="dnn" TagName="DisplayPortalID" Src="~/Portals/_default/Skins/MySkin/MyExternalFiles/MyScript.ascx" %> on your skin file. Create the MyScript.ascx.

2. Place <dnn:DisplayPortalID runat="server"/> on your skin file (MySkin.ascx - where you want to make the portalid appear)

3. Place a following code on your skin file(MySkin.ascx). The code has to be placed AFTER you call <dnn:DisplayPortalID runat="server"/>. If you place it on the bottom of the skin file, that's safe.

<script language="JavaScript">
<!--
 var CurrentPortalID = <%= PortalSettings.ActiveTab.PortalId %>;
 GetPortalID(CurrentPortalID);
//-->
</script>

4. On your "MyScript.ascx" file, place a following code:

<script language="JavaScript">
<!--
function GetPortalID(CurrentPortalID){
document.write(CurrentPortalID)
}

//-->
</script>

This should display PortalID on your site. You can expand the GetPortalID function. You can't call up PortalID directly from MyScript.ascx (your external file). You need to call it on MySkin.ascx ( on Step 3) and call it from MyScript.ascx.

Can somebody explain why it like this? I am not aguring how the skin works.  I just simply can't explain it. Or.... correct me if i am totally wrong.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0get error when get portalID. Please helpget error when get portalID. Please help


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