Common Custom renderers
Common_CustomRenderers_CSharp\SimpleRenderer3D.aspx.cs
// Copyright 2011 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See the use restrictions.
// 

public partial class SimpleRenderer3DPage : System.Web.UI.Page 
{
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (!ScriptManager1.IsInAsyncPostBack)
        {
            // Potential inital load. Check if graphics resource has the graphics layer, and if not, create it
            ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem mapResourceItem =
                MapResourceManager1.ResourceItems.Find("GraphicsDataSource");
            ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource graphicsMapResource =
                mapResourceItem.Resource as ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource;

            if (graphicsMapResource != null)
            {
                // Check whether the map extent is null, meaning the map has not yet been initialized
                if (Map1.Extent == null)
                {
                    // Forces earlier initialization of map and will set map extent
                    ESRI.ArcGIS.ADF.Web.DataSources.IMapResource primaryMapResource =
                        Map1.PrimaryMapResourceInstance;
                }

                // Call helper method in App_Code which generates a random graphics layer.  In real-world situations,
                // the random layer could be replaced with, for instance, the result of a query.  Once the layer is
                // created, apply the renderer and add the layer to the graphics resource.

                // First create a polygon layer...
                ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer featureGraphicsLayer =
                    ESRI.ADF.Samples.Renderers.GenerateGraphicsHelper.CreatePolygonFeatures("polygons", Map1.Extent, 10);
                applyRendererAndAddLayer(graphicsMapResource, featureGraphicsLayer);

                // ...then a polyline layer
                featureGraphicsLayer =
                    ESRI.ADF.Samples.Renderers.GenerateGraphicsHelper.CreatePolylineFeatures("polylines", Map1.Extent, 10);
                applyRendererAndAddLayer(graphicsMapResource, featureGraphicsLayer);
            }

            // Refresh the graphics resource so the newly added layers show up
            Map1.RefreshResource("GraphicsDataSource");
        }
    }

    // Applies the SimpleRenderer3D to the graphics layer and adds it to the resource
    private static void applyRendererAndAddLayer(ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource graphicsMapResource, 
        ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer featureGraphicsLayer)
  {
    if (featureGraphicsLayer != null)
    {
      ESRI.ADF.Samples.Renderers.SimpleRenderer3D simpleRenderer3D = 
                new ESRI.ADF.Samples.Renderers.SimpleRenderer3D();
      simpleRenderer3D.FillColor = System.Drawing.Color.White;
      simpleRenderer3D.HeightColumnName = "Height"; // Name of column which contains the extrusion height
      simpleRenderer3D.ScaleHeight = 50; // Scale height by 50 units
      simpleRenderer3D.MaxHeight = 50; // Limit height to a maximum of 50 pixels
      featureGraphicsLayer.Renderer = simpleRenderer3D; // Apply the renderer

            // If a layer of the same name has already been added, remove it
            if (graphicsMapResource.Graphics.Tables.Contains(featureGraphicsLayer.TableName))
                graphicsMapResource.Graphics.Tables.Remove(featureGraphicsLayer.TableName);

            // Add the passed-in layer
            graphicsMapResource.Graphics.Tables.Add(featureGraphicsLayer);
        }
  }
}