DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Error setting up user control code-behind

 6 Replies
 2 Subscribed to this topic
 19 Subscribed to this forum
Sort:
Author
Messages
New Around Here
Posts: 8
New Around Here

I'm trying to incorporate this non-DNN dev page (http://hstoneart.com/Port...stoneArtGallery.aspx ) into a new page template file. The new file is based on the Xcillion Inner.ascx; the problem is that I can't get the code-behind to work. When I load a page using the new template, I get the error "Could Not Load Theme: /Portals/_default/skins/hstoneartskin/hsa_inr_modal.ascx, Error: E:\web\drawingwork\htdocs\Portals\_default\skins\hstoneartskin\HSA_inr_modal.ascx.vb(11): error ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl)".

The pages appear in Visual Studio Solution Explorer as parent and child. I've Googled and tried different combinations of "Class Name" and "Inherits" values, I've added a Namespace, and I've cleared the VWDWebCache folder and rebuilt the web. I know I must be missing something basic. Can anyone help? Thanks.

Control declaration:
<%@ Control Language="vb" AutoEventWireup="false" Explicit="True" CodeFile="HSA_inr_modal.ascx.vb"  Inherits="hstoneArtGallery" %>

Beginning of code behind:


Imports System
Imports System.IO
Imports System.IO.Directory
Imports System.Web
Imports System.Data

 

Partial Class hstoneArtGallery
    Inherits System.Web.UI.Page

 

 

 

 

 

Veteran Member
Posts: 838
Veteran Member
3 Helpful Replier
Helpful Replier
Thanks for being such a helpful replier!
New Poster
New Poster
Congrats on posting!

I think the editor deleted some of the code you posted? 

Veteran Member
Posts: 1182
Veteran Member
MVP
MVP
You're an MVP!
If you try to write a module, you should inherit the partial class from PortalModuleBase.

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

DNN Connect
New Around Here
Posts: 8
New Around Here

Actually, I left it out. I figured that the code inside the Class tags would be of little interest. Here's the code:

Imports System
Imports System.IO
Imports System.IO.Directory
Imports System.Web
Imports System.Data

Partial Class HstoneArtGallery
    Inherits System.Web.UI.Page

    Function ImportTextFile(ByVal strTextFileName As String) As String
        Dim strTextFilePath As String = Path.GetDirectoryName(Server.MapPath(Me.ToString)) & "\notes\"
        Dim strReturnedText As String
        Using sr As New StreamReader(strTextFilePath & strTextFileName)

            strReturnedText = sr.ReadToEnd()
        End Using

        Return strReturnedText

    End Function

    Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim strPathToImagesFolder As String = Path.GetDirectoryName(Server.MapPath(Me.ToString)) & "\images\"       'declares path to images folder
        Dim strFileSystemEntryImage As String
        Dim arrGetFiles() As String = Directory.GetFiles(strPathToImagesFolder)     'sets up array of files in image folder
        Dim arrFileNames() As String
        Dim strFileName As String
        Dim strCleanedFilename As String
        Dim arrAltTitleTag As Array
        Dim strAltTitleTag As String
        Dim intNameCounter As Integer
        Dim imgAltTag As String
        intNameCounter = 0

        Dim imgID As String

        Dim strThumbnailsMaker As New StringBuilder
        strThumbnailsMaker.Append("

")
        thumbnailsPanel.Controls.Add(New LiteralControl(strThumbnailsMaker.ToString))

    End Sub

    Private Function WriteFileInfo(ByVal strFilenameInfo As String) As String
        Dim arrSplitOnExclamation() As String
        Dim strToReturn As New StringBuilder
        If InStr(strFilenameInfo, "!") > 0 Then
            strFilenameInfo = strFilenameInfo.Replace("_", " ")
            arrSplitOnExclamation = Split(strFilenameInfo, "!")
            Dim arrLastValue() As String
            arrLastValue = Split(arrSplitOnExclamation(5), ".")
            strToReturn.Append("")
            strToReturn.Append(arrSplitOnExclamation(1))
            strToReturn.Append("
, ")
            strToReturn.Append(arrSplitOnExclamation(2))
            strToReturn.Append(", ")
            strToReturn.Append(arrSplitOnExclamation(3))
            strToReturn.Append(", ")
            arrSplitOnExclamation(4) = Replace(arrSplitOnExclamation(4), "in", """")
            strToReturn.Append(arrSplitOnExclamation(4))
            strToReturn.Append(", ")
            strToReturn.Append(arrLastValue(0))
        Else
            strToReturn.Append(" ")
        End If
        Return strToReturn.ToString
    End Function


End Class

-------------------------------

Here's the Control statement at the top of the ascx file:

<%@ Control Language="vb" AutoEventWireup="false" Explicit="True" CodeFile="HSA_inr_modal.ascx.vb" Inherits="HstoneArtGallery" %>

 

New Around Here
Posts: 8
New Around Here

I changed:

Partial Class HstoneArtGallery
    Inherits System.Web.UI.Page

to

Partial Class HstoneArtGallery
    Inherits PortalModuleBase

and the error remained. I probably didn't do that exactly right.

I'm not trying to write a module, just a page template.

 

 

 

 

Veteran Member
Posts: 1182
Veteran Member
MVP
MVP
You're an MVP!
Posted By Britomart on 10 Aug 2022 05:37 PM

I changed:

[...]

I'm not trying to write a module, just a page template.

In that case I would recommend to have a look at one of the multi-purpose modules like OpenContent or 2sxc. It should be easy to achieve your goal with one of these if you're familiar with HTML and JavaScript.

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

DNN Connect
New Around Here
Posts: 8
New Around Here
I couldn't get OpenContent or 2sxc to install; they both went to 95% and stalled. I contacted the host to verify that I had space and checked the web.config and DNN setting to verify that the files weren't too big, still didn't work. I've been trying to figure it out with no luck. I've tried simplified layouts and inline code instead of code-behind. Any attempt to run VB code on any of the test pages generates error "Could Not Load Theme: /Portals/_default/skins/hstoneartskin/hsa_gallerygen.ascx, Error: Unable to cast object of type 'ASP.portals__default_skins_hstoneartskin_hsa_gallerygen_ascx' to type 'DotNetNuke.UI.Skins.Skin'. I've been trying to track that one down without much luck. I have no idea what "Unable to cast object of type" means, and I could find few references on line.
I'm running DNN 9.10.02 in a clean install with a new host.
Here's the admin log entry:
AbsoluteURL:/Default.aspx

DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke

ExceptionGUID:0fa9c969-5832-4cd8-8b15-fb50b0397802

AssemblyVersion:

PortalId:-1

UserId:-1

TabId:-1

RawUrl:

Referrer:

UserAgent:

ExceptionHash:5ZGVzUuVvCZIzAD/onENhymz260=

Message:Unhandled error loading page.

StackTrace:

InnerMessage:Unable to cast object of type 'ASP.portals__default_skins_hstoneartskin_hsa_gallerygen_ascx' to type 'DotNetNuke.UI.Skins.Skin'.

InnerStackTrace:

at DotNetNuke.UI.ControlUtilities.LoadControl[T](TemplateControl containerControl, String ControlSrc)
at DotNetNuke.UI.Skins.Skin.LoadSkin(PageBase page, String skinPath)

Source:

FileName:

FileLineNumber:0

FileColumnNumber:0

Method:

Server Name: web809

What do I do next? Thanks.

These Forums are for the discussion of the open source CMS DNN platform and ecosystem.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
  2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
  3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  5. No Flaming or Trolling.
  6. No Profanity, Racism, or Prejudice.
  7. Site Moderators have the final word on approving / removing a thread or post or comment.
  8. English language posting only, please.

Would you like to help us?

Awesome! Simply post in the forums using the link below and we'll get you started.

Get Involved