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.0Dynamic CSS for each Module InstanceDynamic CSS for each Module Instance
Previous
 
Next
New Post
10/9/2008 7:40 AM
 

Guys,

I have a scenario where i want to specify a different CSS file for each module instance. So for example lets say my module displays Top 5 Latest News Articles. Now i want to drop 2 modules instances of the same module and specify different CSS files for each of them via the module configuration settings. Firstly can i achieve something like this in DNN, if so please help me how do i achieve

 
New Post
10/16/2008 3:35 AM
 

Hi,

What you could do is set a prefix in the tabmodule settings and in your pagebehind code just set the prefix to a public string and include in this prefix in your CssClass of yur ascx file. You would need to create a module control (under host--> module definitions --> your module) with Settings as key and type being Edit and point it to your settings ascx file. Your code behind (C# version) could include within the namespace tag:

partial class Settings : ModuleSettingsBase
{
public override void LoadSettings()
{
try
{
if (Page.IsPostBack == false)
{
if (!(TabModuleSettings["currency"] == null))
{
txtClassPrefix.Text = (string)TabModuleSettings["classprefix"];
}
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
public override void UpdateSettings()
{
try
{
ModuleController objModules = new ModuleController();
objModules.UpdateTabModuleSetting(TabModuleId, "classprefix", txtClassPrefix.Text);
SynchronizeModule(); //(don't remeber if this is depreciated though)
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}}}

and of course have a textbox in your ascx file named txtClassPrefix.
 
In your module you could then (in the code behind) use something like:

....
public string classPrefix;
....

and in your page_load:
.....

if (!(Settings["classprefix"]==null))
{
classPrefix = (string)Settings["classprefix"];
}
else
{
classPrefix = some default value;
}
....
and to use the style in your ascx file just use:
<asp:label id=someid runat=server CssClass="<%=ClassPrefix%>Myclass"

Just create an entry in your css file for each prefix and class combi and you'r done.


Hth

Alexander

 
New Post
10/16/2008 11:09 AM
 

You could do it the way mentioned previously, or do it much easier.  Check out this thread: http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/258642/scope/posts/Default.aspx

Good luck!


-- Jon Seeley
DotNetNuke Modules
Custom DotNetNuke and .NET Development
http://www.seeleyware.com
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Dynamic CSS for each Module InstanceDynamic CSS for each Module Instance


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