Setup

1. Include Z.IconLibrary.dll to your project reference
2. Add a new httpHandlers to your web.config (Required for II6-)

<add path="*/z.axd" verb="*" type="Z.IconLibrary.IconResourceHandler" validate="false" /> 


3. Add a new handlers to your web.config (Required for II7+)

<add name="Z.IconLibrary.RessourceHandler" verb="*" path="*/z.axd" preCondition="integratedMode" type="Z.IconLibrary.IconResourceHandler" /> 


4. Use "Page.AddIconStyleSheet();" to include embedded css class to your page header
or include the css file in your project and include it in your page.

protected void Page_Load(object sender, EventArgs e)
{
        Page.AddIconStyleSheet();
}


Download Web.Config Sample

Methods

Following method can be used in a web project:

  • [Icon].GetCssClass16() // Require handler to be configured in web.config & stylesheet
  • [Icon].GetCssClass32() // Require handler to be configured in web.config & stylesheet
  • [Icon].GetUrl16() // Require handler to be configured in web.config
  • [Icon].GetUrl32() // Require handler to be configured in web.config
  • [Icon].GetWebResourceUrl16()
  • [Icon].GetWebResourceUrl32()

You can also use method used for WinForm project:

  • [Icon].GetBitmap16()
  • [Icon].GetBitmap32()
  • [Icon].GetIcon16()
  • [Icon].GetIcon32()
  • [Icon].GetImage16()
  • [Icon].GetImage32()
  • [Icon].GetStream16()
  • [Icon].GetStream32()

Web Project Examples

Download source code to try Web/WinForm example.



using System;
using System.Web.UI;
using Z.IconLibrary;

namespace Z.Examples.Web
{
    public partial class Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.AddIconStyleSheet();

            if (!Page.IsPostBack)
            {
                uiCssClass16.CssClass = Icon.Accept.GetCssClass16(); // required web.config setup
                uiCssClass32.CssClass = Icon.Accept.GetCssClass32(); // required web.config setup

                uiUrl16.ImageUrl = Icon.Accept.GetUrl16(); // required web.config setup
                uiUrl32.ImageUrl = Icon.Accept.GetUrl32(); // required web.config setup

                uiWebResourceUrl16.ImageUrl = Icon.Accept.GetWebResourceUrl16(); // no requirement
                uiWebResourceUrl32.ImageUrl = Icon.Accept.GetWebResourceUrl32(); // no requirement

                uiIcon.DataSource = Enum.GetValues(typeof(Icon));
                uiIcon.DataBind();
            }

            uiIcon.SelectedIndexChanged += uiIcon_SelectedIndexChanged;
        }

        private void uiIcon_SelectedIndexChanged(object sender, EventArgs e)
        {
            var icon = (Icon)Enum.Parse(typeof(Icon), uiIcon.SelectedValue);

            uiDynamicCssClass16.CssClass = icon.GetCssClass16();
            uiDynamicCssClass32.CssClass = icon.GetCssClass32();

            uiDynamicUrl16.ImageUrl = icon.GetUrl16();
            uiDynamicUrl32.ImageUrl = icon.GetUrl32();

            uiDynamicWebResourceUrl16.ImageUrl = icon.GetWebResourceUrl16();
            uiDynamicWebResourceUrl32.ImageUrl = icon.GetWebResourceUrl32();
        }
    }
}

 

Last edited Feb 15, 2014 at 12:37 PM by Jonathan_Magnan, version 35