Category Archives: Dotnetnuke

DNN 7.4.2 Help Icon Error/Fix

I ran into a a weird bug from a fresh install of DNN 7.4.2. The help icon wouldn’t move. After a little digging, I tracked it down to the default portal’s default.css:

/*.dnnTooltip .dnnFormHelpContent span:after,
.dnnHelperTip .dnnFormHelpContent span:after {
position: absolute;
content: "";
left: 15px;
bottom: -7px;
width: 0;
height: 0;
opacity: 0.75;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top: 7px solid #000;
}*/

.dnnTooltip .dnnFormHelpContent .dnnHelpText {
word-wrap: break-word;
}

.bottomArrow:after
{
position: absolute;
content: "";
left: 15px;
bottom: -7px;
width: 0;
height: 0;
opacity: 0.75;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top: 7px solid #000;
}
.topArrow:before {
position: absolute;
content: "";
left: 15px;
top: -7px;
width: 0;
height: 0;
opacity: 0.75;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #000;
}

It seems the old tool tip css, was commented out and a new section put in. It wasn’t working for me so I just reverted things. I hope this didn’t break anything, and for now I hope it helps someone else:

.dnnTooltip .dnnFormHelpContent span:after, .dnnHelperTip .dnnFormHelpContent span:after {
position: absolute;
content: "";
left: 15px;
bottom: -7px;
width: 0;
height: 0;
opacity: 0.75;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top: 7px solid #000;
}

/*
.dnnTooltip .dnnFormHelpContent .dnnHelpText {
word-wrap: break-word;
}

.bottomArrow:after
{
position: absolute;
content: "";
left: 15px;
bottom: -7px;
width: 0;
height: 0;
opacity: 0.75;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top: 7px solid #000;
}
.topArrow:before {
position: absolute;
content: "";
left: 15px;
top: -7px;
width: 0;
height: 0;
opacity: 0.75;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #000;
}
*/

Javascript, Query, & Dotnetnuke Postback

Work started getting slow a few months back, so I started programming again. My sites needed updating. I also had a few upgrades in mind. One in particular was highlighting all desired text on a certain page. I found nice JavaScript snippet here:

http://www.nsftools.com/misc/SearchAndHighlight.htm

//<script language=”JavaScript”>
function doHighlight(spanText, searchTerm, highlightStartTag, highlightEndTag) {
// the highlightStartTag and highlightEndTag parameters are optional
if ((!highlightStartTag) || (!highlightEndTag)) {
highlightStartTag = “<font style=’background-color:yellow;’>”;
highlightEndTag = “</font>”;
}
var newText = “”;
var i = -1;
var lcSearchTerm = searchTerm.toLowerCase();
var lcSpanText = spanText.toLowerCase();
while (spanText.length > 0) {
i = lcSpanText.indexOf(lcSearchTerm, i + 1);
if (i < 0) {
newText += spanText;
spanText = “”;
} else {
// skip anything inside an HTML tag
if (spanText.lastIndexOf(“>”, i) >= spanText.lastIndexOf(“<“, i)) {
// skip anything inside a <script> block
if (lcSpanText.lastIndexOf(“/script>”, i) >= lcSpanText.lastIndexOf(“<script”, i)) {
// skip anything inside a <HyperLink> block
if (lcSpanText.lastIndexOf(“/asp:HyperLink>”, i) >= lcSpanText.lastIndexOf(“<asp:HyperLink”, i)) {
// skip anything inside a <linkbutton> block
if (lcSpanText.lastIndexOf(“/asp:linkbutton>”, i) >= lcSpanText.lastIndexOf(“<asp:linkbutton”, i)) {
// skip anything inside a <Checkbox> block
if (lcSpanText.lastIndexOf(“/asp:Checkbox>”, i) >= lcSpanText.lastIndexOf(“<asp:Checkbox”, i)) {
// skip anything inside a <panel> block
if (lcSpanText.lastIndexOf(“/asp:panel>”, i) >= lcSpanText.lastIndexOf(“<asp:panel”, i)) {
// skip anything inside a <legend> block
if (lcSpanText.lastIndexOf(“legend>”, i) >= lcSpanText.lastIndexOf(“<legend”, i)) {
newText += spanText.substring(0, i) + highlightStartTag + spanText.substr(i, searchTerm.length) + highlightEndTag;
spanText = spanText.substr(i + searchTerm.length);
lcSpanText = spanText.toLowerCase();
i = -1;
}
}
}
}
}
}
}
}
}
return newText;
return false;
}
function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag) {
if (treatAsPhrase) {
searchArray = [searchText];
} else {
searchArray = searchText.split(” “);
}
if (!document.getElementById(“spanText”) || typeof (document.getElementById(“spanText”).innerHTML) == “undefined”) {
if (warnOnFailure) {
Sorry, for some reason the text of this page is unavailable. Searching will not work.”);
}
return false;
}
var spanText = document.getElementById(“spanText”).innerHTML;
for (var i = 0; i < searchArray.length; i++) {
spanText = doHighlight(spanText, searchArray[i], highlightStartTag, highlightEndTag);
}
document.getElementById(“spanText”).innerHTML = spanText;
return false;
}
function badphrases(){
highlightSearchTerms(‘die kill’);
}
//window.onload(setTimeout(‘badphrases();’,3000));
//</script>

The code worked beautifully when I tested it’s search then highlight functions. BUT when I tested it against the rest of the page I realized that my buttons weren’t working anymore. Something was going wrong and after playing with how the script loaded, what to block it from replacing, and where it highlighted I gave up.

Another solution had to be found. Knowing that Dotnetnuke had jQuery integrated into it I tried this jQuery plugin:

http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html

Ostensibly, it looked like a winner like the last one. NO!, something was still wrong. Further inspection told me that the JavaScript was messing with DNN’s method of posting back. After some more trial and error I went to the DNN forums:

http://www.dnnsoftware.com/forums/forumid/199/threadid/503867/scope/posts

javascript and asp.net postbacks are somewhat at odds with each other under certain circumstances.
This is especially the case if there are any async / partial update panels on the page
– something that is more and more common these days.

That’s what I got, though it didn’t help much. I told me that I shouldn’t give up and after a little more searching I found my code: http://bartaz.github.io/sandbox.js/jquery.highlight.html

<style>.highlight { background-color: yellow; }</style>

<script language=”javascript” type=”text/javascript”>

jQuery.fn.highlight = function(pat) {
function innerHighlight(node, pat) {
var skip = 0;
if (node.nodeType == 3) {
var pos = node.data.toUpperCase().indexOf(pat);
if (pos >= 0) {
var spannode = document.createElement(‘span’);
spannode.className = ‘highlight’;
var middlebit = node.splitText(pos);
var endbit = middlebit.splitText(pat.length);
var middleclone = middlebit.cloneNode(true);
spannode.appendChild(middleclone);
middlebit.parentNode.replaceChild(spannode, middlebit);
skip = 1;
}
}
else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
for (var i = 0; i < node.childNodes.length; ++i) {
i += innerHighlight(node.childNodes[i], pat);
}
}
return skip;
}
return this.length && pat && pat.length ? this.each(function() {
innerHighlight(this, pat.toUpperCase());
}) : this;
};

$(document).ready(function(){
$(“td”).highlight(“kill”);
});

</script>

Thank you Bartaz and Johann for the nice code. Bartaz’s updated code did the trick. I hope this helps someone else working with Dotnetnuke. Happy Coding to all!

 

Bad GoDaddy Customer Service

Last night, I noticed a couple of my sites were down, both hosted on GoDaddy. After talking to support for about an hour and hearing that it was my fault. I did my own check up and restarted the application pool for ASP.net. That worked.

But this post is not about there servers randomly going down. It’s about another bad customer service experience I had with GoDaddy support. Every time I asked for the support expert (ha) to check to see if something had gone wrong on their end he said, “nothing has gone wrong, your site is scripted wrong.” Even after explaining that I had not touched my site in ages and the other was install by GoDaddy… he continued to disregard any my suggestion/queries has to what might have gone wrong.  In the end all I wanted was the sites up and not to point a finger.

I even started a post on their forums and without surprise other users have been experiencing the same problems for 30+ hours. Honestly they could have just checked and might have found/suggested something like “please try restarting your application pool?!?!”

http://community.godaddy.com/groups/web-hosting/forum/topic/sites-down-1/

It gets worst they edited any (if not) all the comments on the forums that made the server failures their fault. Again saying it’s our fault. Big time, NO NO!!!

After writing this I will still keep the sites mention with them because moving the sites will be such a hassle and their prices are one of the lowest for Windows hosting. But as for future sites and any potential customers they might have had going to them from me… the count is now ZERO.

So if you are considering GoDaddy web hosting. Be very very careful.

[rating:2/5]

-Thuan

DNN RADeditor Config’ing

A few weeks back I updated all my DNN sites to 5.4.4. Primarily to take advantage of ASP.net 3.5, but I also needed to come to terms with the fact that skins are now treated as modules. There were many other changes, one that came as a surprise was that FCKeditor was no longer DNN’s default editor. Telerik’s RADeditor was the new big guy in town and works just as well, but better in that it has more tools. The most useful tool that I have already taken advantage of is it’s spell checker. With that said, can there be too many tools? Tools that some of us will never use? YES!!! This is where the RADeditor’s configurability comes in handy. If you are looking to remove some of the tools from the default configuration, then edit this file…

DNN/Providers/HtmlEditorProviders/Telerik/Config/ToolsDefault.xml

I suggest that you only comment out the tools that you don’t want, you might find them handy later on…

If you look within the DNN/Providers/HtmlEditorProviders/Telerik/ folder you will also find the EditorOverride.css file. Which I found I needed to edit because by default the editor used the same “imaged background” and “centered” properties the site used.

Finally, if you find that you don’t like Telerik’s RADeditor, you can always revert back to the original FCKeditor via the web.config file…

find:
<htmlEditor defaultProvider=”TelerikEditorProvider“>
… change it to:
<htmlEditor defaultProvider=”FckHtmlEditorProvider“>

Happy Coding,
Thuan

Dotnetnuke Error: BC30451

For all interested parties if you run into this error after compiling a custom module…

Dotnetnuke BC30451: Name ‘Initialize’ is not declared.

It is most likely you didn’t change your reference paths in Visual Studio.

Brian Dukes ran into this problem, discussed here. His solution was to copy a fresh copy of the core Dotnetnuke.dll into your root /bin folders but if you don’t change the reference paths in Visual Studio, each time you compile your custom module the Dotnetnuke.dll will be replaced with the an older one if it exists.

Don’t forget to change the reference paths for both your main module project and the corresponding sqldataprovider project because it will also have the same reference paths.

HTH, Thuan.

Dotnetnuke Infinite Redirect Loop

It had be a long time since I had worked with Dotnetnuke but it was time for me to upgrade a few of my Dotnetnuke sites.  And as always DNN’s installation/upgrading is again culpable for all my recent stress.

The site upgrade in question was going from DNN 3.3.7 to DNN 4.9.0 and the error I kept on getting was an infinite loop redirecting me back to this URL: http://mysite/default.aspx?alias=http://mysite/myalias with a blank screen.

Internet Explorer didn’t know what to do with it so it infinitely reloaded the URL.  Firefox was a little smarter, it detected the loop therefore stopped it and gave out this error message: “Firefox has detected that the server is redirecting the request for this address in a way that will never complete.”

So the search was on, using these keywords… dotnetnuke, infinite, redirect, and loop. I found a couple promising articles with potential solutions to my problem…

http://www.bestwebsites.co.nz/dotnetnuke/solving-the-dotnetnuke-redirect-loop/

http://weblogs.asp.net/christoc/archive/2008/06/19/dotnetnuke-homepage-won-t-load-keeps-redirecting.aspx

But after  much trial and error with my trust settings and going straight to the database and changing my portal’s aliases per those solutions, I was still at a dead end.

It wasn’t until I carefully read this John Mitchell forum thread did I find my solution. The problem was the new Default.aspx page. After the upgrade the page code went from…

<%@ Page Language=”vb” AutoEventWireup=”false” Explicit=”True” Inherits=”DotNetNuke.Framework.DefaultPage” CodeFile=”Default.aspx.vb” %>
<%@ Register TagPrefix=”dnn” Namespace=”DotNetNuke.Common.Controls” Assembly=”DotNetNuke” %>
<asp:literal id=”skinDocType” runat=”server”></asp:literal>
<html <%=xmlns%> <%=LanguageCode%>>
<head id=”Head” runat=”server”>
<meta id=”MetaRefresh” runat=”Server” http-equiv=”Refresh” name=”Refresh” />
<meta id=”MetaDescription” runat=”Server” name=”DESCRIPTION” />
<meta id=”MetaKeywords” runat=”Server” name=”KEYWORDS” />
<meta id=”MetaCopyright” runat=”Server” name=”COPYRIGHT” />
<meta id=”MetaGenerator” runat=”Server” name=”GENERATOR” />
<meta id=”MetaAuthor” runat=”Server” name=”AUTHOR” />
<meta name=”RESOURCE-TYPE” content=”DOCUMENT” />
<meta name=”DISTRIBUTION” content=”GLOBAL” />
<meta name=”ROBOTS” content=”INDEX, FOLLOW” />
<meta name=”REVISIT-AFTER” content=”1 DAYS” />
<meta name=”RATING” content=”GENERAL” />
<meta http-equiv=”PAGE-ENTER” content=”RevealTrans(Duration=0,Transition=1)” />
<style type=”text/css” id=”StylePlaceholder” runat=”server”></style>
<asp:placeholder id=”CSS” runat=”server” />
</head>
<body id=”Body” runat=”server” >
<noscript></noscript>
<dnn:Form id=”Form” runat=”server” ENCTYPE=”multipart/form-data” style=”height: 100%;” autocomplete=”off”>
<asp:Label ID=”SkinError” runat=”server” CssClass=”NormalRed” Visible=”False”></asp:Label>
<asp:PlaceHolder ID=”SkinPlaceHolder” runat=”server” />
<input id=”ScrollTop” runat=”server” name=”ScrollTop” type=”hidden” />
<input id=”__dnnVariable” runat=”server” name=”__dnnVariable” type=”hidden” />
</dnn:Form>
</body>
</html>

to…

<%@ Page language=”VB” %>
<%@ Import Namespace=”DotNetNuke” %>

<script runat=”server”>

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

Dim DomainName As String
Dim ServerPath As String
Dim URL() As String
Dim intURL As Integer

‘ parse the Request URL into a Domain Name token
URL = Split(Request.Url.ToString(), “/”)
For intURL = 2 To URL.GetUpperBound(0)
Select Case URL(intURL).ToLower
Case “admin”, “desktopmodules”, “mobilemodules”, “premiummodules”
Exit For
Case Else
‘ check if filename
If InStr(1, URL(intURL), “.aspx”) = 0 Then
DomainName = DomainName & IIf(DomainName <> “”, “/”, “”) & URL(intURL)
Else
Exit For
End If
End Select
Next intURL

‘ format the Request.ApplicationPath
ServerPath = Request.ApplicationPath
If Mid(ServerPath, Len(ServerPath), 1) <> “/” Then
ServerPath = ServerPath & “/”
End If

DomainName = ServerPath & “Default.aspx?alias=” & DomainName

Response.Redirect(DomainName,True)

End Sub

</script>

This made me look at all my files a second time. What I found was that the old Default.aspx was backed up as old_Default.aspx and a new one was created. So my solution was simply to replace the original Default.aspx page with the new one generated from the upgrade.

And although, my solution got the site working again and under ASP.NET v2 (the reason for my upgrade), it also leaves me to question what I did, if I messed anything fundamental up, and why the Dotnetnuke Team changed the Default.aspx page.

If anyone could enlighten me on this, please leave a comment.

ASP.net 1.1 Repeater Columns

While writing a script to mass approve posts on a site, similar to deleting all unwanted email using: a repeater (not a datagrid), a checkbox in each indexItem, and a button; I ran into a common problem for many… ASP.net repeaters don’t have columns. I searched the net and visited two of my favorite forums looking for help and came up with nothing…

Here’s my Psuedo/Logic:
1) Load Repeater with list of “UNmoderated” items
2) Put a checkbox inside the repeaters ItemTemplate
3) Add code to button (dosomething if checkbox is checked)

Problem:
I couldn’t locate the column with the PrimaryUniqueID because there are no columns in repeaters, but my Stored Procedure “requires” the PrimaryUniqueID.

Button code:
Private Sub MassApprove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MassApprove.Click
Try
Dim MyRptItem As RepeaterItem
For Each MyRptItem In MyRepeater.Items
Dim chbxMassApprove As CheckBox = CType(MyRptItem.FindControl(“chbxMassApprove”), CheckBox)
Dim PrimaryUniqueID As String = MyRptItem.DataItem(PrimaryUniqueID) PROBLEMATIC LINE
If chbxMassApprove.Checked = True Then
‘DO THE MASS APPROVE
‘LOOP THRU STORED PROCEDURE
End If
Next
Catch exc As Exception
Response.Write(exc.ToString)
End Try
End Sub

Solution:
I used this as a workaround if this helps anyone…

Front End:
Text='<%# DataBinder.Eval(Container, “DataItem.PrimaryUniqueID”) %>’

Back End:
Dim PrimaryUniqueID As String = ckbxMassApprove.Text.ToString

ASP.net Paging

So, the users of a certain website of mine have been requesting that I add paging to one of my controls. I initially didn’t want to do it, not because I couldn’t do it. But because the control didn’t really call for it. But they are my users, without them the site wouldn’t be there right? So I went ahead with it. Its been a while since I used any paging code, so I was refreshed after reviewing ASP.net paging webcontrols:

System.Web.UI.WebControls.PagedDataSource

What we have to do for us to paging through our data vs. displaying all of it at once? We simply inject the paging into our data before displaying it. In my case, I am using a repeater:

'get the data
Dim myData As System.Collections.ArrayList
myData = ** myStoredProcedure **
'ensure there is data to work with
If myData .Count > 0 Then
'create a new instance of PagedDataSource
myPagedDataSource = New System.Web.UI.WebControls.PagedDataSource
'set my pagin preferences
myPagedDataSource.DataSource = myData
myPagedDataSource.AllowPaging = True
myPagedDataSource.PageSize = 5
myPagedDataSource.CurrentPageIndex = myCurrentPageIndex
'then finally bind the data to my repeater
myRepeater.DataSource = myPagedDataSource
myRepeater.DataBind()
End If

Quite simple to use. Knowing that the webcontrol is there really is the hard part of it all.

DNN Installs

Installing DNN on shared hosting as always been a hard task. And to think I’d have it down by now. I at least remember by heart the basics:

  1. Download the software from the DNN site
  2. Upload the files to the shared hosting
  3. Ensure permissions for the ASP.net user are correct
  4. Setup the database and user
  5. Config the webconfig, ie. enter in the DB connection data/string
  6. Go to browser, invoke install @ http://mydomain.com/install
  7. Change admin and host passwords

Thats is normally it, unless you run into permissions problems; which is often on shared hosting servers.

But while trying to setup my Freedotnetnukeskins.com on Lunarpages.com servers, we (support and I) discovered that the directory “skins” CANNOT be used as your virtual directory. My guess is this might be in the DNN manual somewhere, but we were using the “auto install DNN” plesk so it was hard to pick out.