HtmlListAdapter.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / MIT / System / Web / UI / MobileControls / Adapters / HtmlListAdapter.cs / 1305376 / HtmlListAdapter.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

using System; 
using System.IO; 
using System.Web;
using System.Web.UI; 
using System.Web.UI.HtmlControls;
using System.Web.UI.MobileControls;
using System.Security.Permissions;
using System.Globalization; 

#if COMPILING_FOR_SHIPPED_SOURCE 
namespace System.Web.UI.MobileControls.ShippedAdapterSource 
#else
namespace System.Web.UI.MobileControls.Adapters 
#endif

{
    /* 
     * HtmlListAdapter provides the html device functionality for List controls.
     * 
     * Copyright (c) 2000 Microsoft Corporation 
     */
    ///  
    [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
    [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")]
    public class HtmlListAdapter : HtmlControlAdapter 
    {
        ///  
        protected new List Control 
        {
            get 
            {
                return (List)base.Control;
            }
        } 

        ///  
        public override void Render(HtmlMobileTextWriter writer) 
        {
            if(Control.HasControls()) 
            {
                RenderChildren(writer);
                return;
            } 
            RenderList(writer);
        } 
 
        /// 
        protected virtual void RenderList(HtmlMobileTextWriter writer) 
        {
            MobileListItemCollection items = Control.Items;
            Wrapping wrap = Style.Wrapping; // used for tables, no decoration case.
            if (items.Count == 0) 
            {
                return; 
            } 

            int pageStart = Control.FirstVisibleItemIndex; 
            int pageSize = Control.VisibleItemCount;

            // Determine what markup to use.
 
            String listSuffix, itemPrefix, itemSuffix;
            ListDecoration decoration = Control.Decoration; 
            bool insideStyle = true; 

            // We know that for table tag, outer style doesn't carry over 
            // into inside tags so style state needs to be reset.
            // For other cases, we enter the style here once and exit at the
            // end once.
            if (decoration != ListDecoration.None || !Device.Tables) 
            {
                writer.EnterStyle(Style); 
                insideStyle = false; 
            }
 
            switch (decoration)
            {
                case ListDecoration.Bulleted:
                    writer.WriteLine("
    "); listSuffix = "
"; itemPrefix = "
  • "; itemSuffix = "
  • "; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "
    "; } break; case ListDecoration.Numbered: if (pageStart == 0) { writer.WriteLine("
      "); } else { writer.Write("
        "); } listSuffix = "
      "; itemPrefix = "
    1. "; itemSuffix = "
    2. "; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "
      "; } break; default: if (Device.Tables) { listSuffix = ""; Style.Wrapping = Wrapping.NotSet; writer.EnterLayout(Style); writer.WriteLine(""); if(wrap == Wrapping.NoWrap) { itemPrefix = ""; } else { listSuffix = String.Empty; itemPrefix = String.Empty; itemSuffix = "
      "; } break; } bool hasCmdHandler = Control.HasItemCommandHandler; for (int i = 0; i < pageSize; i++) { MobileListItem item = items[pageStart + i]; writer.Write(itemPrefix); if(insideStyle) { writer.BeginStyleContext(); writer.EnterFormat(Style); } if(Control.ItemsAsLinks) { RenderBeginLink(writer, item.Value); } else if(hasCmdHandler) { writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", item.Index.ToString(CultureInfo.InvariantCulture)); writer.Write(">"); } writer.WriteEncodedText(item.Text); if (hasCmdHandler || Control.ItemsAsLinks) { RenderEndLink(writer); } if(insideStyle) { writer.ExitFormat(Style); writer.EndStyleContext(); } writer.WriteLine(itemSuffix); } if (listSuffix == null || listSuffix.Length > 0) { writer.WriteLine(listSuffix); } if (decoration != ListDecoration.None || !Device.Tables) { writer.ExitStyle(Style); } else { writer.ExitLayout(Style); Style.Wrapping = wrap; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.IO; using System.Web; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.MobileControls; using System.Security.Permissions; using System.Globalization; #if COMPILING_FOR_SHIPPED_SOURCE namespace System.Web.UI.MobileControls.ShippedAdapterSource #else namespace System.Web.UI.MobileControls.Adapters #endif { /* * HtmlListAdapter provides the html device functionality for List controls. * * Copyright (c) 2000 Microsoft Corporation */ /// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)] [Obsolete("The System.Web.Mobile.dll assembly has been deprecated and should no longer be used. For information about how to develop ASP.NET mobile applications, see http://go.microsoft.com/fwlink/?LinkId=157231.")] public class HtmlListAdapter : HtmlControlAdapter { /// protected new List Control { get { return (List)base.Control; } } /// public override void Render(HtmlMobileTextWriter writer) { if(Control.HasControls()) { RenderChildren(writer); return; } RenderList(writer); } /// protected virtual void RenderList(HtmlMobileTextWriter writer) { MobileListItemCollection items = Control.Items; Wrapping wrap = Style.Wrapping; // used for tables, no decoration case. if (items.Count == 0) { return; } int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; // Determine what markup to use. String listSuffix, itemPrefix, itemSuffix; ListDecoration decoration = Control.Decoration; bool insideStyle = true; // We know that for table tag, outer style doesn't carry over // into inside tags so style state needs to be reset. // For other cases, we enter the style here once and exit at the // end once. if (decoration != ListDecoration.None || !Device.Tables) { writer.EnterStyle(Style); insideStyle = false; } switch (decoration) { case ListDecoration.Bulleted: writer.WriteLine("
        "); listSuffix = "
      "; itemPrefix = "
    3. "; itemSuffix = "
    4. "; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "
      "; } break; case ListDecoration.Numbered: if (pageStart == 0) { writer.WriteLine("
        "); } else { writer.Write("
          "); } listSuffix = "
        "; itemPrefix = "
      1. "; itemSuffix = "
      2. "; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "
        "; } break; default: if (Device.Tables) { listSuffix = "
      "; } else { itemPrefix = "
      "; } itemSuffix = "
      "; Style.Wrapping = Wrapping.NotSet; writer.EnterLayout(Style); writer.WriteLine(""); if(wrap == Wrapping.NoWrap) { itemPrefix = ""; } else { listSuffix = String.Empty; itemPrefix = String.Empty; itemSuffix = "
      "; } break; } bool hasCmdHandler = Control.HasItemCommandHandler; for (int i = 0; i < pageSize; i++) { MobileListItem item = items[pageStart + i]; writer.Write(itemPrefix); if(insideStyle) { writer.BeginStyleContext(); writer.EnterFormat(Style); } if(Control.ItemsAsLinks) { RenderBeginLink(writer, item.Value); } else if(hasCmdHandler) { writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", item.Index.ToString(CultureInfo.InvariantCulture)); writer.Write(">"); } writer.WriteEncodedText(item.Text); if (hasCmdHandler || Control.ItemsAsLinks) { RenderEndLink(writer); } if(insideStyle) { writer.ExitFormat(Style); writer.EndStyleContext(); } writer.WriteLine(itemSuffix); } if (listSuffix == null || listSuffix.Length > 0) { writer.WriteLine(listSuffix); } if (decoration != ListDecoration.None || !Device.Tables) { writer.ExitStyle(Style); } else { writer.ExitLayout(Style); Style.Wrapping = wrap; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.

      Link Menu

      Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
      This book is available now!
      Buy at Amazon US or
      Buy at Amazon UK

      "; } else { itemPrefix = "
      "; } itemSuffix = "