DNN Forums

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

Changing the title of a module control programmatically

Sort:
You are not authorized to post a reply.





Veteran Member





    It is easy to change the title of a module programmatically, something like

    private void Page_Init(object sender, System.EventArgs e){
       ModuleConfiguration.ModuleTitle = "Whatever";
    }

    But how can I do this for a control (eg. "Edit"). I know it is possible in the resource file by adding a key "ControlTitle_edit", but is this possible from the code behind somehow?

    Happy DNNing!
    Michael

     

    Michael Tobisch
    DNN★MVP

    dnnWerk Austria
    DNN Connect





    Veteran Member





      Hmmm... That's a fantastic question. I've never tried to do that. I've only used the resource file to update that value. 🤔





      Veteran Member





        I found somethng in an old code I wrote some years ago:

        protected override void OnPreRender(EventArgs e)
        {
           ModuleContext.Configuration.ModuleTitle = Localization.GetString("Whatever", LocalResourceFile);
           base.OnPreRender(e);
        }

        I am sure that worked at the time I wrote it, but it does not anymore. I tried to use this instead of the code above:

        protected override void OnPreRender(EventArgs e)
        {
           ModuleContext.Configuration.ModuleControl.ControlTitle = Localization.GetString("Whatever", LocalResourceFile);
           base.OnPreRender(e);
        }

        No luck. Anyone who can bring light into the darkness? Is it a bug?

        Happy DNNing!
        Michael

        Michael Tobisch
        DNN★MVP

        dnnWerk Austria
        DNN Connect





        New Around Here





          I recently had this exact same need and found what you have works in the OnInit function:
          
          protected override void OnInit(EventArgs e)
          {
               ModuleConfiguration.ModuleControl.ControlTitle = Localization.GetString("Whatever", LocalResourceFile);
               base.OnInit(e);
          } 
          

          Be sure to have Whatever.Text as the name for the string in the .resx file.





          Veteran Member





            Posted By Ryan Jagdfeld on 9/5/2023 1:14 PM
            I recently had this exact same need and found what you have works in the OnInit function:
             protected override void OnInit(EventArgs e) {      ModuleConfiguration.ModuleControl.ControlTitle = Localization.GetString("Whatever", LocalResourceFile);      base.OnInit(e); } 

            Be sure to have Whatever.Text as the name for the string in the .resx file.

            Oh wow... Now that I'm seeing this code sample, it's reminding me that this is something I USED to know!  🤣 

             

             

            You are not authorized to post a reply.

            These Forums are dedicated to the discussion of DNN Platform.

            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