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.0Change Text Size ModuleChange Text Size Module
Previous
 
Next
New Post
5/26/2007 4:58 PM
 

Hello All

 

Ive just converted a feature from a site i am upgrading to dnn.  which was to have a drop downlist change the text size of the page content.

 

Ive hacked it together in about half an hour, and although it works, i would like some feedback from people with greater experience than me with DNN, im sure there are better ways to use its features than i have (this is my first module btw)

 

The user control code is as follows :

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="textsize.ascx.vb" Inherits="DesktopModules_TextSize_textsize" %>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="100%">
    <asp:ListItem Value="3">X Large</asp:ListItem>
    <asp:ListItem Value="2">Large</asp:ListItem>
    <asp:ListItem Selected="True" Value="1">Medium</asp:ListItem>
    <asp:ListItem Value="0">Small</asp:ListItem>
</asp:DropDownList>

and the code behind :

Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Security.PortalSecurity
Partial Class DesktopModules_TextSize_textsize
    Inherits Entities.Modules.PortalModuleBase
'Users changes font size
    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
'Set Profile Value
        DotNetNuke.Services.Personalization.Personalization.SetProfile(ModuleId.ToString, "textsize", Me.DropDownList1.SelectedIndex)
'Set session value
        Session("textsize") = Me.DropDownList1.SelectedIndex
    End Sub

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        Dim iTxtSize As Int32
'Is the user logged in
        If UserId > -1 Then
            iTxtSize = DotNetNuke.Services.Personalization.Personalization.GetProfile(ModuleId.ToString, "textsize")
        Else
'check if the anon user has a value stored in session
            If Session("textsize").ToString.Length > 0 Then
                iTxtSize = Int32.Parse(Session("textsize"))
            Else
'Otherwise set text size to medium, and store in session
                iTxtSize = 2
                Session("textsize") =
iTxtSize
            End If
        End If
        Dim TextSize As New Style()
        Select Case iTxtSize
            Case 0 'XL
                TextSize.Font.Size = FontUnit.Parse("1.4em")
            Case 1 'L
                TextSize.Font.Size = FontUnit.Parse("1.2em")
            Case 2 'M
                TextSize.Font.Size = FontUnit.Parse("1em")
            Case 3 'S
                TextSize.Font.Size = FontUnit.Parse("0.8em")
        End Select
'override '.normal' css class's font size
        Me.Page.Header.StyleSheet.CreateStyleRule(TextSize, Nothing, ".normal")
'Set the selected index of the DDL
        Me.DropDownList1.SelectedIndex = iTxtSize
    End Sub
End Class

i created an additional profile property called textsize to allow the uses preferences to be saved for registed users between sessions, and a session based value is used for anon users to maintain there prefs across pages during there session

 

any comments greatfully taken

 

chuBb.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Change Text Size ModuleChange Text Size Module


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