Imports System.Collections.Generic
Imports CharterDotCom.CommonEntities.Library
Imports CharterDotCom.CommonEntities.Library.Enumerations
Imports CharterDotCom.CommonEntities.Library.EntityMemberServices
'Imports CharterDotCom.CommonEntities.Library.EntityEBSServices
Imports CharterDotCom.CommonEntities.Library.EntitySupport
Imports CharterDotCom.CommonEntities.Library.EntitySearch
Imports CharterDotCom.CommonEntities.Library.EntityWebConfig
'Imports CharterDotCom.CommonEntities.Library.EntityG2BServices
Imports CharterDotCom.CommonEntities.Library.Common
Imports CharterDotCom.WebSite.Library

Partial Class Controls_CustomContentDiv
    Inherits System.Web.UI.UserControl

    Public Property ContentKey() As String
        Get
            If ViewState(Me.ID & "_ContentKey") Is Nothing Then
                Return Nothing
            Else
                Return CType(ViewState(Me.ID & "_ContentKey"), String)
            End If
        End Get

        Set(ByVal value As String)
            ViewState(Me.ID & "_ContentKey") = value
        End Set
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.User.IsInRole(RoleName.Author) Then
            divContent.Style("border") = "red solid 1px"
            divContent.Attributes("onclick") = String.Format("top.editor.location.href='{0}/Authors/Editor.aspx?{1}={2}&{3}={4}&{5}={6}'", _
             Request.ApplicationPath, QueryStringName.OwnerTypeID, OwnerType.Other.GetHashCode(), _
             QueryStringName.OwnerID, 0, QueryStringName.ControlID, ContentKey)
        Else
            divContent.Style("border") = "0"
            divContent.Attributes.Remove("onclick")
        End If
    End Sub

    Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        If ContentKey IsNot Nothing Then
            ltrContent.Text = ContentManager.Instance.GetContent(ContentKey, 1, OwnerType.Other)

            If ltrContent.Text = String.Empty Then
                ltrContent.Text = "ControlID : " & ContentKey
            End If

            txtContentKey.Value = ContentKey
        End If
    End Sub

End Class
