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

HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Changing module title from C#Changing module title from C#
Previous
 
Next
New Post
6/27/2011 9:09 AM
 
Hi,

How do I change title of a module from its inside using C#? I tried couple of properties name like this.%title, but they didn't work.
 
New Post
6/27/2011 8:56 PM
 
The module title actually renders as a part of the module's container. While it is possible to change the title that the module displays from the module control's code behind, using the following assignment this must be done during the module control's Page_Init handler. Any later in the control's life cycle and the change will not be displayed:

this.ModuleConfiguration.ModuleTitle = "My New Module Title";


Another approach and the one that I use as it can be done later in the Load or even the PreRender event handlers is to find the Label control which displays the module's title in its container and set its Text property to the desired title. Here's a C# method for you:

private void SetModuleTitle(string Title)
{
    if (!string.IsNullOrEmpty(Title))
    {
        var ctl = DotNetNuke.Common.Globals.FindControlRecursiveDown(ContainerControl, "lblTitle");

        if (ctl != null)
        {
            ((System.Web.UI.WebControls.Label)ctl).Text = Title;
        }
    }
}

Note that this code will fail should the id of the container's title label control ever be changed from "lblTitle". So far across DNN 4, 5 and now 6.0 it has remained the same.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
6/28/2011 10:27 AM
 
Thanks, I used the second method and it worked great.
 
New Post
8/13/2011 9:51 AM
 
FWIW - this method does not work with DNN600 Release under some circumstances.

ModuleConfiguration.ModuleTitle = Title;

is the correct way to do it in DNN600 - the new container renders the module title from this value.

Westa

 
New Post
10/4/2011 1:26 PM
 
So as of DNN6 there is no way to change the Title on-the-fly at PageLoad?

Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
Previous
 
Next
HomeHomeGetting StartedGetting StartedNew to DNN Plat...New to DNN Plat...Changing module title from C#Changing module title from C#


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