Modify a DNN Module without touching the ASCX

What do you do when you get a module for DotNetNuke, either one that comes with it, or one that you obtain from a third party, and you want to change the presentation layer?

I would imagine that many people would just open up the ascx file, make the change, and be done with it. But, if you do that, what happens when you install an upgrade to that module?

Of course, you’ll have to make the change all over again. And we all know that when you upgrade, you’ll forget about the modification for a few weeks. But, what if there were some way of making those changes without having to touch the original ascx files?

There are two ways you might do this. One would be to create and install a filter on the server side that rearranges the html on the way back to the server. This is probably the best method as it is not dependant on server side technology. However, it may take a bit more tweaking to get it right and is only available to .NET programmers.

The second method, and one I’ve used with great success, is to use a Text/HTML module and insert JavaScript that reads the DOM and rewrites the HTML. I have come to call this “JavaScript Re-Writes”

I’ve used this to:

  • Remove text from a module that I don’t want to have displayed.
  • Insert text into a module that was missing
  • Hide links I want the spiders to see, but I don’t want the end user to see (note: there are times when this is appropriate and times when it is an SEO trick that is sure to backfire. Know the difference before you implement it.)
  • Insert tooltips over elements that should have them but don’t.
  • Change link buttons that use text to graphic buttons.

The beauty is, when I upgrade, 99% of the time, the DOM doesn’t change and my changes are still in effect. Further, anyone who knows JavaScript can make the change and they don’t have to be a .NET programmer to do it.

Related Post

  • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it wrong, which...
  • Changing an Existing DNN ModuleChanging an Existing DNN Module Got this question this morning from the “Ask A Question” form. “How do I make a change in an existing DotNetNuke module?  I want to add new fields to the feedback form.” I’m assuming the ...
  • DotNetNuke Response.End() Doesn’t EndDotNetNuke Response.End() Doesn’t End OK.  This one is just plain annoying! For some reason that I’ve yet to be able to track down, Response.End() seems to have no impact at all under DotNetNuke. I tried various hacks.  Including...
  • Upload a File via WebRequest Using CSharpUpload a File via WebRequest Using CSharp I got this question a couple of weeks ago but just never had the time to put into answering fully.  But today I have some extra time due to the fact that I’m under-booked with projects. Th...
  • Modifying Copies of a Session ObjectModifying Copies of a Session Object This morning I woke up to the following question in my inbox: I am storing an object into session. Then in one of my functions I am copying that session object into a local object and doing some ...