Custom event log in Dotnetnuke
Hello,
Easy way to log events in the event log is as follows
Method 1:
DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();
objEventLog.AddLog(“Error Message”, “Some error has occurred while processing”, PortalSettings,UserInfo.UserID, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT);
Method 2:
DotNetNuke.Services.Log.EventLog.LogInfo logInfo = new DotNetNuke.Services.Log.EventLog.LogInfo();
logInfo.LogUserID = UserId;
logInfo.LogPortalID = PortalSettings.PortalId;
logInfo.LogTypeKey = EventLogController.EventLogType.ADMIN_ALERT.ToString();
logInfo.AddProperty(“Test Property 1″, StringValue1);
logInfo.AddProperty(“Test Property 2″, StringValue2);
eventLog.AddLog(logInfo);
Creating a custom exception in Dotnetnuke
Hello,
There is a very simple way of creating a custom exception in dotnetnuke. All that you need is the custom text as the error message as shown below.
DotNetNuke.Services.Exceptions.Exceptions.LogException(new Exception(“Error processing information”));
Changing the module title on runtime in dotnetnuke
I was recently working on something related to displaying the module title for a dotnetnuke module at runtime. It’s quite simple, here’s how to achieve it.
Put the code mentioned below either in the Page_Load or the Page_PreRender events
Control m_Control = DotNetNuke.Common.Globals.FindControlRecursiveDown(this.ContainerControl, “lblTitle”);
if ((m_Control != null))
{
((Label)m_Control).Text += “This is the module title”;
}
That’s it!
Set default value to a property
Hello !
Just a few days back I found out that setting default values to a property is very simple, Just follow the steps mentioned below -
- Make sure that you are using System.ComponentModel – (using System.ComponentModel;)
- Set the [DefaultValueAttribute("")] before the property
e.g.
[DefaultValueAttribute("")]
public string Website
{
get { return m_website; }
set { m_website = value; }
}
DefaultValueAttribute accepts various parameters, Use the desired one.
ASPNET user not created after the microsoft framework installation
Recently I ran into a problem where I had to format my machine and then get VS 2008 and SQL Server 2005 installed on my machine all over again. The installation went through fine but for some reason while installing DNN I was unable to find aspnet user (I needed it to give appropriate permissions to the DNN install folder). I am sure you guys might sooner or later run into the same problem.
The solution is really very simple. Just browse to the framework 2.0 folder and reset framework 2.0 as the currently installed framework by using aspnet_regiis -i
That’s it, Now try to find the user and you should be able to find it and set appropriate permissions on the DNN install folder.
DNN Performance tip
There are times when it takes ages for the DNN login page to load and its really frustrating to just sit and wait for the login page to appear on the screen. There could be many reasons for this to happen, but the most common one is to do with the authentication settings, if the DNN authentication settings are not correctly setup it takes a while for DNN to figure out which authentication provider to show to you thus causing a delay in loading up the login screen. If you are using multiple providers then there’s not much you can do about the settings. In case you are using the standard DNN authentication, here’s what you can do to speed up the loading of the login page -
- Login as a host into the system
- Go to the authentication settings(for DNN 4.XX the option is Host->Host Settings, for DNN 5.XX the option is Host->Extensions)
- Disable the “Open ID” and the “Live ID” providers which are enabled by default due to obligations with the providers
- Save the settings
The trick here is to disable all the providers that you don’t need.
Debugging the javascript using the “Debugger” keyword
Dotnetnuke developers usually write custom javascripts to meet their project needs or need to debug the pre-existing ones, they usually find it difficult to debug javascript. I came across a very simple way to get the visual studio IDE to debug javascript.It is using the “debugger;” keyword. Before using this there are a couple of things that you will have to do,
- Open up IE and select the “Tools->Options” menu
- Uncheck the disable script debugging(Internet Explorer)
- Uncheck the disale script debugging(Other)
- All the you have to do now is to place the “debugger;” keyword in the javascript at the place where you want the javascript to break
With the above mentioned steps you will be able to break into the code and the control will be returned to the visual studio IDE.
Clearing the dotnetnuke search tables
Hi,
WHERE SearchItemWordId IN (SELECT SearchItemWordId FROM SearchItemWordWHERE SearchItemID IN (SELECT SearchItemId FROM SearchItem))
WHERE SearchWordsId IN (SELECT SearchWordsId FROM SearchItemWord WHERE SearchItemID IN ( SELECT SearchItemId FROM SearchItem))
Unable to start debugging on the web server.The web server is not configured correctly.
Setting up a DNN source project can be easy and difficult at the same time. Since this is an open source product code files have been modified by more than 1 DNN developer.
Recently I tried installing a source version on DNN 04.09.04. It was pretty simple and it worked like a charm, the problem started when I installed the source version (01.00.05) of the active directory module. I included it successfully in the project and hit the F5 button of the VS 2005 only to know that I received an error “Unable to start debugging on the web server.The web server is not configured correctly.”
Here’s what helped me fix the problem -
- Right click the DotNetNuke.Authentication.ActiveDirectory.VS2005 and select the “Properties” option
- Select the “WEB” tab of the project properties
- In the “Servers” option incase “Use IIS Web server” option is selected, ensure that the project URL is the correct one, also ensure that the “Override application root URL” is the correct one.
- Click the Save button from the toolbar.
Now just hit F5 and the application should run fine.