Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Custom skin controls using csharp in codebehind?Custom skin controls using csharp in codebehind?
Previous
 
Next
New Post
5/3/2007 11:29 AM
 
Is it possible to use c# for developing custom skin controls? Why and Why not? I know that you can develop modules with c#. But I am not sure about skin objects.

For example, I have bellow a skin control called header.ascx which uses vb as primary language. But I want the header.ascx codebehind to be in c#.

Skin File snippet
<%@ Control language="vb" CodeBehind="~/admin/Skins/skin.vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %>
<%@ Register TagPrefix="dnn" TagName="HEADER" Src="~/Admin/Skins/Header.ascx" %>


Where Header.ascx would use
<%@ Control language="C#" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Controls.Header" CodeFile="Header.ascx.cs" Debug="True" %>


Rod
 
New Post
5/4/2007 4:58 AM
 

Change the default language to C# in the page directive, gives a codefile CODEFILE="HADER.ASCX" and inherits from the class defined in the HEADER.ASCX

Something like : partial class header : UserControl  {}

 
New Post
5/4/2007 10:07 AM
 
What I did to test it is I just copied and renamed the files terms.ascx and terms.ascx.vb under admin/skins to Header.ascx and Header.ascx.cs. Next I converted the vb file to C# using this web site:

http://www.carlosag.net/Tools/CodeTranslator/Default.aspx

The interesting thing is that the skin loads fine but the codebehind is not loading. I tried debugging in VS.2005 and it doesnt' work. However the debug works for the original version in vb.


On your post when you say that you have to inherit usercontrol you mean UI.Skins.SkinObjectBase right? If this code works the way it is in vb why wouldn't work after conversion? I think that there is something that is missing in the conversion.

Here is the code to test:

<%@ Control language="C#" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Controls.Header" CodeFile="Header.ascx.cs" %>




namespace DotNetNuke.UI.Skins.Controls {


class Header : UI.Skins.SkinObjectBase {

// private members
private string _text;

private string _cssClass;

const string MyFileName = "Header.ascx";

public string Text {
get {
return _text;
}
set {
_text = value;
}
}

public string CssClass {
get {
return _cssClass;
}
set {
_cssClass = value;
}
}

[System.Diagnostics.DebuggerStepThrough()]
private void InitializeComponent() {
}

private void Page_Init(object sender, System.EventArgs e) {
// CODEGEN: This method call is required by the Web Form Designer
// Do not modify it using the code editor.
InitializeComponent();
}

// *******************************************************
//
// The Page_Load server event handler on this page is used
// to populate the role information for the page
//
// *******************************************************
private void Page_Load(object sender, System.EventArgs e) {
try {
// public attributes
if ((CssClass != "")) {
hypHeader.CssClass = CssClass;
}
if ((Text != "")) {
hypHeader.Text = Text;
}
else {
hypHeader.Text = Services.Localization.Localization.GetString("Header", Services.Localization.Localization.GetResourceFile(this, MyFileName));
}
hypHeader.NavigateUrl = NavigateURL("Header");
}
catch (Exception exc) {
// Module failed to load
ProcessModuleLoadException(this, exc);
}
}
}
}




Thanks

Rod
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Custom skin controls using csharp in codebehind?Custom skin controls using csharp in codebehind?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

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

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. 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.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out