Reputation: 27813
I am trying to make an ascx control that can be templated by our front-end developers by just making a new .ascx and pointing to that specific .ascx in that instance. However, I am having issues with accessing properties in shared code-behind scenarios.
I have the following code behind that's shared
public partial class TemplateCodeBehind : TemplateControlBase
{
protected void Page_Load(object sender, EventArgs e)
{
}
// Ascx Available properties
public string GetOption1Value { get { return Option1; } }
public string GetOption2Value { get { return Option2; } }
public string GetOption3Value { get { return Option3; } }
public string GetOption4Value { get { return Option4; } }
}
Note that those options that are returned are public properties of the TemplateControlBase
class. In my Templates subfolder I have the following ascx
<%@ Control Language="C#" AutoEventWireup="false" CodeBehind="../TemplateCodeBehind.ascx.cs" Inherits="MyNamespace.JqueryTemplates.TemplateCodeBehind" %>
<%@ Import Namespace="MyNamespace.JqueryTemplates" %>
<div>
Option1: <%= GetOption1 %>
</div>
This compiles fine, but when I try to load my test ascx I get the following error
An error has occurred. DotNetNuke.Services.Exceptions.PageLoadException: c:\Projects\DNN-Dev\Website\DesktopModules\Module.JqueryTemplates\Templates\Test.ascx(5): error CS0103: The name 'GetOption1' does not exist in the current context
I have tried changing <%=
to <%#
and calling Page.Databind()
but nothing seems to work.
Any ideas on how I can accomplish this?
Upvotes: 0
Views: 719