DNN Forums

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

Changing the title of a module control programmatically

 4 Replies
 3 Subscribed to this topic
 26 Subscribed to this forum
Sort:
Author
Messages
Veteran Member
Posts: 1182
Veteran Member
MVP
MVP
You're an MVP!

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

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

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

DNN Connect
Senior Member
Posts: 1607
Senior Member
MVP
MVP
You're an MVP!
New Poster
New Poster
Congrats on posting!
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
Posts: 1182
Veteran Member
MVP
MVP
You're an MVP!

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

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

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:

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

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

Happy DNNing!
Michael

Michael Tobisch
DNN★MVP

DNN Connect
New Around Here
Posts: 6
New Around Here
I recently had this exact same need and found what you have works in the OnInit function:
[code] protected override void OnInit(EventArgs e) {      ModuleConfiguration.ModuleControl.ControlTitle = Localization.GetString("Whatever", LocalResourceFile);      base.OnInit(e); } [/code]
Be sure to have Whatever.Text as the name for the string in the .resx file.
Senior Member
Posts: 1607
Senior Member
MVP
MVP
You're an MVP!
New Poster
New Poster
Congrats on posting!
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:
[code] protected override void OnInit(EventArgs e) {      ModuleConfiguration.ModuleControl.ControlTitle = Localization.GetString("Whatever", LocalResourceFile);      base.OnInit(e); } [/code]
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!  🤣 

 

 

These Forums are for the discussion of the open source CMS DNN platform and ecosystem.

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