This topic has not yet been rated - Rate this topic

SiteLogoImage Class

Represents a site logo.

System.Object
  System.Web.UI.Control
    System.Web.UI.WebControls.WebControl
      System.Web.UI.WebControls.Image
        Microsoft.SharePoint.WebControls.SiteLogoImage

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SiteLogoImage : Image
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
SiteLogoImage
Description

The Microsoft.SharePoint.WebControls.SiteLogoImage class inherits from the System.Web.UI.Design.WebControls.Image class allowing you to conditionally instantiate the current site logo as an image web control.

First the control gets a SPWeb from the current request context to see whether the SPWeb.SiteLogoUrl property is null or empty. This property is evident from a SharePoint site within “Site Settings” under “Title, Description, and Icon”. If a value is present, it is used for image rendering. If not, the LogoImageUrl property from the SiteLogoImage class is queried for a URL to the site logo, providing a way to supply an alternative image URL. If both properties are null or empty, then the standard blank.gif placeholder is used.

You should note that the image will also query the SPWeb.SiteLogoDescription property for alternate image text. If this is not available, the GenerateEmptyAlternateText method from the inherited Image class will be called in order to populate the image alternate text attribute.

Usage Scenario

You typically use the SiteLogoImage control when you need to build heavily customized site elements, or display your site logos in locations within custom application interfaces.

The following code samples show how you might use the SiteLogoImage within a WebPart:

C# Code Example

protected override void CreateChildControls()
 {
    // Orthodox Control Creation And Addition
    SiteLogoImage image = new SiteLogoImage();
    Controls.Add(image);
    // This Will Call The GenerateEmptyAlternateText Method
    SiteLogoImage image = new SiteLogoImage();
    image.AlternateText = string.Empty;
    Controls.Add(image);
    // Provide A Alternative Logo Url
    SiteLogoImage image = new SiteLogoImage();
    image.LogoImageUrl = "_layout/images/my_custom_image.jpg";
    Controls.Add(image);        
    base.CreateChildControls();
}

Visual Basic .NET Code Example

Protected Overloads Overrides Sub CreateChildControls()
    ' Orthodox Control Creation And Addition
    Dim image As New SiteLogoImage()
    Controls.Add(image)
    ' This Will Call The GenerateEmptyAlternateText Method
    Dim image As New SiteLogoImage()
    image.AlternateText = String.Empty
    Controls.Add(image)
    ' Provide A Alternative Logo Url
    Dim image As New SiteLogoImage()
    image.LogoImageUrl = "_layout/images/my_custom_image.jpg"
    Controls.Add(image)    
    MyBase.CreateChildControls()
End Sub

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com