How to insert Javascript on DNN page?

by Naveen 19. July 2010 04:33

During the process of setting up a new DotnetNuke site, I needed to put a google adsense javascript on the page. I think there is some DNN module that you can use to do so as well. But I also needed to put another javascript block from another advertising vendor on the page as well. First I though may be I can inject the script block in HTML module content itself. Unfortunately HTML editor removes javascript from content when it gets saved. After looking around at various page setting, I found that I could put my javascript code under Header available under Module Settings > Advanced Settings section in module settings. You can see this in action at the following URL. Sections shown at top and left of the page are HTML modules that have javascript embedded in header.

Embed Javascript In Module Demo

Give your advice to big bosses and make money

Views: 354

Tags: ,

DotNetNuke

How to deploy another web application under DNN as virtual directory

by Naveen 31. March 2010 05:37

Here is the scenario that this post is about. You have an existing DotNetNuke (DNN). Now you have to configure a new ASP.Net web application under this site as virtual directory. So you follow the standard procedure of creating a new virtual directory under your parent DNN site and point it to the location where the new web application's files are. Try to access this site and you will run into the following error.


Server Error in '/DNN53/ProductsSearch' Application.
--------------------------------------------------------------------------------

Configuration Error 
Description: An error occurred during the processing of a configuration 
file required to service this request. Please review the specific error details
below and modify your configuration file appropriately. 

Parser Error Message: The code subdirectory '/DNN53/ProductsSearch/App_Code/IFrame/' 
does not exist.

Source Error: 

Line 168:      -->
Line 169:      <codeSubDirectories>
Line 170:        <add directoryName="IFrame" />
Line 171:        <add directoryName="Survey" />
Line 172:        <add directoryName="XML" />

Source File: C:\Projects\DNN\DNN_V531\Install\web.config    Line: 170

Now you are wondering what does these folders and files have to do anything with your web application that is hosted under DNN site. The thing that you need to understand is that when you are hosting a child application under parent ASP.Net application, it inherits web.config settings from all the parents as well. So in this case your application is inheriting DNN related settings as well. I have some one suggesting to add these missing folders in your new application as well. Next thing you will run into is that your site is complaining about missing DNN related assemblies.

The solution to this problem is not copy DNN assemblies or mimic the folder structure in your application as well. Because now you have added a very strong dependency on parent application. There is a very simple and elegant solution to this problem.

  • Open Web.config file of your parent DNN site.
  • Look for system.web entry in the file.
  • Enclose that whole section in location tag and set the attributes of that tag as below.
    
    <location path="" inheritInChildApplications="false">
     <system.web>
    ..
    ..
     </system.web>
    </location>
    
    
  • By setting inheritInChildApplications to false you indicate to ASP.Net pipe line that any settings for the specified path and for the section are not to be propagated to the child application.

You can use this technique to restrict propagation on page by page or by folders etc.

Give your advice to big bosses and make money

Views: 1345

Tags: ,

ASP.Net | DotNetNuke

How to fix Security Error When Installing DNN On Windows 7

by Naveen 31. March 2010 04:48

When you install DotNetNuke (in my case it was latest 5.3.1 release), you may run into the following exception and error when you try to launch the wizard for fresh install. This error can actually occur even after you have configured your DNN site correctly.


Server Error in '/DNN53' Application.
-------------------------------------

Security Exception
Description: The application attempted to perform an operation not allowed by
the security policy.  To grant this application the required permission please
contact your system administrator or change the application's trust level in 
the configuration file.

Exception Details:
System.Security.SecurityException: Request for the permission of type 
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed

The issue here is related how you created and configured your virtual directory or web application in IIS7 or higher. When creating a virtual directory in IIS on Windows 7, the default setting make use of DefaultAppPool. And that pool is configured to use Integrated Pipe Line as shown in the following screenshot. DNN framework does not seem to be configured and implemented to handle this integrated IIS pipeline and ends up throwing security exception. The simple fix is to switch your application pool to use Classic .Net AppPool or if you have some other custom application pool that does not use Integrated pipe line.

Give your advice to big bosses and make money

Views: 1692

Tags: , , ,

DotNetNuke | IIS | Windows 7

How to customize Privacy Statement and Terms and Conditions pages in DNN

by Naveen 1. February 2010 06:53

While developing a web site for one of my clients, I needed to put custom Privacy and Terms & User page. After digging around I found that the text that gets displayed on these pages from default implementation of Privacy and Terms control is saved as resource in resources. When I went to look at the page where you enter the text I got ticked off. There was a tiny square text box where you needed to put the text. Yes, I know I could create the HTML for those pages in some nifty HTML editor like Expression or Dreamweaver and then paste it there. That worked fine but then there was another issue. I needed to show a common module on all pages. This default implementation did not do it for me even though I had marked a module to show on all pages of the site.

If you hover on Privacy and Terms of user link, you will see that it is pointing to pages Privacy.aspx and Terms.aspx. Then it clicked to me that if I add new pages into the system with names Privacy and Terms it may override the default implementation.

I created two new pages in the system with the names Privacy and Terms and it worked. Since I did not want these pages to be showing as menu options in top or other navigation bars, so make sure that when you add these new pages you check off the option of not including them in menu.

Give your advice to big bosses and make money

Views: 1945

Tags:

DotNetNuke

Online DNN Dotnetnuke API Help

by Naveen 28. December 2009 07:41

Every time I am doing custom DNN module development, one thing will bug me all the time is having access to DNN Core API documentation. A lot of time I do not have access to local CHM file for help. That's when I used to wish if I had some place where online help is available for core api. So this x-mas i decided to be my own Santa Clause and give myself gift of online DNN core api help site. So here it is, You can click on the following link to visit my site where I have hosted DNN 5.2 Core API Help Documentation


Give your advice to big bosses and make money

Views: 2174

Tags: ,

DotNetNuke

How to find current logged in user in DotNetNuke

by Naveen 18. December 2009 05:33

While developing DotNetNuke modules a lot of time you need to add features that have role based access control. To authorize the access, you will need the following set of information about the current user.

  • Is it authenticated session or anonymous user?
  • If its authenticated, who is the user?
  • What role(s) this user belongs to?
  • And other permissions related about information about the user

If you are not very familiar with DNN core API, then getting this information is not very obvious. And lack on online documentation of DNN API kind of makes it hard to search API as well. The API is very well done and has appropriate method names. But if there was an index, then it will be just quickly searching and getting the information.

Anyways, in DNN core, look in DotNetNuke.Entities.Users namespace. You will find two very useful classes UserController and UserInfo classes. As you may have guessed, these are two objects that you need to get user information. UserController has a static/friend method GetCurrentUserInfo that returns a UserInfo object. You can inspect this returned object to get more details about the user. For example, following code snippet shows how to find current logged in user in DNN and if this user is in particular role or not.


Dim userInfo = UserController.GetCurrentUserInfo()
if (userInfo.IsInRole("Manager")) Then
' Do some manager related work here
End If

You can explore UserInfo object to see what all you can do with it. Here is another example code that shows how to find all the roles of a user in DNN.

Dim userInfo = UserController.GetCurrentUserInfo()
Dim userRoles = userInfo.Roles

As you can see, the method names are very intutive and implemented at right place. Its just matter of knowing where to look for. If you have any questions about any DNN API, please feel free to drop me a line.

Give your advice to big bosses and make money

Views: 2200

Tags: ,

DotNetNuke

How to debug DNN module

by Viper 17. November 2009 11:45

In last two posts, Setting up development environment and Implenting custom DNN module, I have described you will do custom DNN module development. Now comes the fun part. How are you going to debug your module. Since your module gets loaded inside DotnetNuke site, the debugging requires change in your project settings.

Need Debug Build

When you used NANT build tool to create package for deployment, it uses release build options. So the assembly for your module does not have DEBUG option turned on in your site. What you can do is that do a DEBUG build of your project and replace module assemblies in BIN folder of your DNN site with the DEBUG version. Or you can make some change in NANT build file for your project to create a DEBUG package and then deploy that. If you are not comfortable with NANT build file, then go with the first option I mentioned.

Change Project Setting

One option you have it to change target start URL that gets invoked when hit F5 or choose Debug > Start Debugging menu option. To do that, bring up Properties of module project. Goto Web tab on the dialog box. You can select Use local web server or Use custom web server radio button and then specify the URL for your DNN installation. Now you will be able to break into your module.

Attach to Process

Other option you have is to choose Debug > Attach to process menu option and then attach to ASP.Net process. And then put break points in your module to debug the problems.

If you are looking into debugging your DNN modules on live site then I will be discussing that in one of my later posts about how you can incorporate logging and diagnostics into your module.

Give your advice to big bosses and make money

Views: 2594

Tags: , ,

DotNetNuke

How to develop DotnetNuke Module - Implementation of module

by Viper 17. November 2009 06:27

Download Module Project

In previous post Develop DotnetNuke Module - Setting up environment, I described how you will go about setting up your development environment. Now I will start discussion on developing a DNN custom module as stand alone assembly using C#. I have named this module as ByteBlocks: AmazonProducts. The module displays products from Amazon.com store based on product category and search keywords. For this to use in your web site, you will need to have an associate account with Amazon.com. This is totally free and you can get started by clicking here.

Click here to see this module in action


New Project

Select File > New > Project menu option to create new project. In my case, I named it AmazonProducts. This will create a new C# project for you. The project template adds lot of boiler plate code for you to get started. In this post I will explain the files that are absolutely basic to get started with module development. Before you start doing anything, run NANT build tool to make sure that your project compiles. And check that there is a folder named package under the project folder. And this folder should contain four ZIP files in it. If this step goes smoothly, that means you have your development set up correctly and you are ready to rock with module development.

Lets look at some of the files that got added to your project.

.dnn file

This is the file that defines metadata for your module. What this means is that this where you specify how your module is structured, files it contains and other settings. Open this file. This is a XML file. All the node names are very intuitive and very quickly you will figure out what these means. If you are building a single view and single assembly module then you will not have to make any changes under Controls and Files node. For more complex modules that require more files to be included and other things then you will be made to define those settings in these sections. For now, leave it the way it is. Make sure that you have name of the module specified that is relevant to functionality of your module.

View{projectname}.ascx

This is the file where you will implement VIEW of your module. What this means is that this is the control that gets loaded in DNN framework when users come to your site. If you open {projectname}.dnn file you will find a node under controls that looks as below.

<control>
 <src>DesktopModules/AmazonProducts/ViewAmazonProducts.ascx</src>
 <type>View</type>
 <helpurl></helpurl>
</control>

This is the node where you indicate to DNN framework what all controls are going to be used a view for the data. If you have multiple views for your module then you will need to add entries for those views in {projectname}.dnn file. I will explain in another post how you will deal with multiple views and how you will load them at run time based on their IDs and things like that. In this sample module I only have one view.

Settings{projectname}.ascx

This is the control that gets loaded when you invoke settings of a module. DNN framework loads your implementation combined with the base implementation provided by the framework to show settings for the module. If you do not have any custom settings for your module then you do not have to add any content to it. Also open {projectname}.dnn and notice that you have a node like below in there.

<control>
 <key>Settings</key>
 <title>AmazonProducts Settings</title>
 <src>DesktopModules/AmazonProducts/Settings.ascx</src>
 <type>Edit</type>
 <helpurl></helpurl>
</control>

Edit{projectname}.ascx

This is a very important control implementation in your module. If your control requires some input to configure it to run it, then you can use this control to implement gathering of those settings. For example in the sample module, you need to gather 2 very important pieces of information to get data from Amazon.com web service. The images below shows you how a new link Amazon Account Set up appears when you are logged in as an admin and clicking on it brings up a view where you can specify the settings for the module.

Open {projectname}.dnn file you will find a node as shown below.

<control>
 <key<Edit</key<
 <title<Edit Content</title<
 <src<DesktopModules/AmazonProducts/EditAmazonProducts.ascx</src<
 <type<Edit</type<
 <helpurl<</helpurl<
</control<

There are some very important points about how you indicate to DNN framework that this is the control that is going to be used for EDIT. One you have noticed in the DNN file that type has been set to Edit. Second is in your implementation. You have to implement IActionable interface in View{projectname}.ascx control. In that implement you indicate to DNN framework what all other actions can be performed by this module. The project template does not add boiler plate code for this interface in your module. You will have to add it yourself. For example, in the sample project the implementation of the class looks as below.

public partial class ViewAmazonProducts : 
   AmazonProductsModuleBase, IActionable
{....}

Add implementation

Now that you have set up the boiler plate code for your module, it is time to fill it with implementation. You will just go about the implementation as you are doing regular ASP.Net user control implementation. The sample project contains complete implementation of rendering product lists from amazon.com. This code was implemented during .Net1.1 days so lot of code may be obsolete and not optimized according to recent changes. But it will give you get started with your DNN module development.

Compile It

Now that you have finished adding implementation of your module, it is time to see it in action. You can use your Visual Studio to a build of the project and resolve any compile errors. Once all errors have been taken care of, fire up NANT build to create package for your module. You will notice four ZIP files created in package folder.

Install It

Once you have created package for your module, you are ready to install it in your DNN framework. Fire up DNN site and login with HOST account. Yes, you will need to log in as HOST. Once logged in, under HOST menu option, select Module Definitions option. This will bring up list of all modules installed in your installation. On that page at the top you will see a dropdown icon next to Module Definitions. Hover mouse on it and it will bring up menu options. Select Install module option as show below.

In the first step you will be asked to select location of your module package. Point to package folder under your project or wherever you copied the ZIP files created for your module. After that follow the instructions and you will have your module loaded and ready to use on any page in your site.

Use It

Once you are done with installation of module package, it shall be visible in list of modules available for your site. Just follow your usual steps of adding a module on any page on your site and you are good to go.

Debugging

In the next post, I will explain how you can go about debugging a DNN module.

Give your advice to big bosses and make money

Views: 2686

Tags: ,

DotNetNuke

How to develop DotnetNuke Module - Setup Development Environment

by Viper 16. November 2009 14:20

This is multi-part series on how to write a custom DotnetNuke module as an independent assembly. This series is not about how to add content and configure containers, pages etc. in DNN framework. There are lot of resources available that explain those things in a very details manner. This series of posts are focusing strictly on module development. This post will get you started with getting your development environment set up.

Setting up development environment for DNN module development

I am going to focus mainly on developing DNN module using C#. It does not mean that these concepts do not apply to VB.Net or any other .Net languages. And also I do not have anything against VB.Net. It is just that my main development platform is C#.

Install DNN

First thing you will need is to have DNN site running on your local machine which you will be using to test your modules with. You can download the package from DotNetNuke web site. I will strongly recommend that you download source package instead of just the installation package. This will help you in debugging underlying DNN framework code as well or to step into the implementation to see whats going on. Once you have downloaded the package, follow the installation instructions to get your DNN site up and running on your local machine.

Install DNN Module Project Template

There are few templates available out there that you can download and install in your development environment to use with Visual Studio. I am using Visual Studio 2008 currently so all references I will mention are going to be be targeted to VS2008 environment. I have been using project template published by Engage. They have provided instructions to install it as well. I will put list the set up instructions here as well.

  • Close all instance of Visual Studio on your machine.
  • Save the downloaded project template ZIP file in C:\Documents and Settings\{user name}\My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual Web Developer. Note that this location is for VS2008 templates. Depending on how you have configured your Visual Studio installation, this location may be different on your machine. Very important that you do not unzip the template compressed file. It needs to be copied as a ZIP file. Otherwise your visual studio will not pick it up.
  • Start Visual Studio instance and select File >New > Project menu option. You should see the new project template installed under My Templates section as shown in picture below. dnn compiled project template

If you can not locate the project template files on Engage web site, let me know. I can try to provide you the template that I use. You will just have to deal with the modifications I have done to it to show my company name and things like that.

Install NANT Build Tool

The project template that you installed from step creates a NANT build file along with other files for module. This NANT build file helps in building and packaging your module correctly. You can compile the project without NANT build tool. But then you will have to make sure that you have packaged the required files. The NANT file generated by this template just takes care of all the steps. If there are some custom requirements, you can always open the NANT file to edit it. You can download latest NANT build tool from Sourceforge.

Now that you have basic infrastructure set up for module development, let's get started with creating our module project. I have created a module that is used to display products from amazon.com based on the product category and search keywords. You will be able to download the whole source for that module in the next post. So lets get started with it.

Developing Amazon.com Products Store Module

Give your advice to big bosses and make money

Views: 2702

Tags: ,

DotNetNuke

Using DotNetNuke for first time

by Viper 23. October 2009 05:20

I just finished putting together a quick web site for a client using DotNetNuke framework. This was my first time creating a site from scratch using DNN. I have done plenty of custom ASP.Net web sites from scratch in the past. I heard a lot, in the past, about DNN as a quick way to put together some decent sites. But when I came to know that it is developed in VB.Net, I held my self back. It is not that VB.Net is inferior language. But having strong background in C/C++/C# and not very extensive experience in VB always kind of not like any VB.Net development. I have done plenty of VB.Net development but not by choice. I kind of digressed from main topic, sorry about that.

My overall experience was pretty good about new version of DotNetNuke. In the past I did maintenance work on a DNN site that was built with V1.0 of the framework. And it was not a pretty experience for me. But I am pleased with how quickly I was able to put together the site for the client. There are some quirks but like any other good software, it is not going to be perfect and make everybody happy. I think law of 80-20 works very well. If it works 100% for 80% of the people then it did its job. And for rest 20%, it provides hooks to customize the things around.

Give your advice to big bosses and make money

Views: 764

Tags:

DotNetNuke

Powered by BlogEngine.NET 1.5.1.7
Theme by Naveen Kohli

By Categories