I am trying to play around with this interesting article about creating a dnn skinobject. I 've successfully managed to replicate the author's code. I placed 3 pieces of gif images, made the reference to them in the xml file it works beautifully.
However when I change something in the vb file it will not show the changes when I reload dotnetnuke portal on the browser. It seems to be caching it and only reading the inherits part of the ascx file. I tested and it is not even touching the codebehind reference to the vb file....
What I don't understand is if the original code work then how is it rendering the code in the vb file? Anyhelp I would appreciate.
This is the article link:
http://www.wwwcoder.com/tabid/68/type/art/parentid/224/site/6373/default.aspx
These are my files:
########################## ImageRotator.ascx ##############################
<%@ Control Language="vb" AutoEventWireup="false" Inherits="DotNetNuke.ImageRotator" CodeBehind="ImageRotator.ascx.vb" %>
######################Horizontal Menu - Fixed Width.ascx ###################
<%@ Register TagPrefix="lrd" TagName="ROTIMAGE" Src="~/SkinObjects/RotatingImage/ImageRotator.ascx" %>
.
.
.
#################ImageRotator.ascx.vb####################
Imports System.Web
Imports System.Xml
Imports System.Xml.XPath
Imports DotNetNuke
Namespace DotNetNuke
Public MustInherit Class ImageRotator
Inherits DotNetNuke.UI.Skins.SkinObjectBase
Protected WithEvents imgMain As System.Web.UI.WebControls.Image
Private mXMLFile As String = "default.xml"
#Region "Public Members"
Public Property XMLFile() As String
Get
Return mXMLFile
End Get
Set(ByVal Value As String)
mXMLFile = Value
End Set
End Property
#End Region
#Region "Event Handlers"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
GetImageInfo()
Catch exc As Exception 'Module failed to load
DotNetNuke.Services.Exceptions.ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
#Region "Private Members"
Private Sub GetImageInfo()
Dim xpathDoc As XPathDocument
Dim xmlNav As XPathNavigator
Dim xmlNI As XPathNodeIterator
xpathDoc = New XPathDocument(Server.MapPath(DotNetNuke.Common.ApplicationPath) & "\SkinObjects\RotatingImage\" & mXMLFile)
xmlNav = xpathDoc.CreateNavigator()
xmlNI = xmlNav.Select("/images/image")
Dim rndNode As Integer = RandomNumber(xmlNI.Count(), 0)
Dim xCnt As Integer = 0
While (xmlNI.MoveNext())
If xCnt = rndNode Then
imgMain.ImageUrl = xmlNI.Current.GetAttribute("src", "")
imgMain.AlternateText = xmlNI.Current.GetAttribute("alt", "")
End If
xCnt = xCnt + 1
End While
End Sub
Private Function RandomNumber(ByVal MaxNumber As Integer, Optional ByVal MinNumber As Integer = 0) As Integer
'initialize random number generator
Dim r As New Random(System.DateTime.Now.Millisecond)
'if passed incorrect arguments, swap them
'can also throw exception or return 0
If MinNumber > MaxNumber Then
Dim t As Integer = MinNumber
MinNumber = MaxNumber
MaxNumber = t
End If
Return r.Next(MinNumber, MaxNumber)
End Function
#End Region
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
End Class
End Namespace
Thank you
Rod