/// <include file='doc\HtmlImageAdapter.uex' path='docs/doc[@for="HtmlImageAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            String target = Control.NavigateUrl;

            writer.EnterLayout(Style);
            if (!String.IsNullOrEmpty(target))
            {
                RenderBeginLink(writer, target);
            }

            if (String.IsNullOrEmpty(Control.ImageUrl))
            {
                // Just write the alternate as text
                writer.EnsureStyle();
                writer.MarkStyleContext();
                writer.EnterFormat(Style);
                writer.WriteText(Control.AlternateText, true);
                writer.ExitFormat(Style);
                writer.UnMarkStyleContext();
            }
            else
            {
                RenderImage(writer);
            }

            if (!String.IsNullOrEmpty(target))
            {
                RenderEndLink(writer);
            }
            writer.ExitLayout(Style, Control.BreakAfter);
        }
        /// <include file='doc\HtmlImageAdapter.uex' path='docs/doc[@for="HtmlImageAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            String target = Control.NavigateUrl;

            writer.EnterLayout(Style);
            if (!String.IsNullOrEmpty(target))
            {
                RenderBeginLink(writer, target);
            }

            if (String.IsNullOrEmpty(Control.ImageUrl))
            {
                // Just write the alternate as text
                writer.EnsureStyle();
                writer.MarkStyleContext();
                writer.EnterFormat(Style);
                writer.WriteText(Control.AlternateText, true);
                writer.ExitFormat(Style);
                writer.UnMarkStyleContext();
            }
            else
            {
                RenderImage(writer);
            }

            if (!String.IsNullOrEmpty(target))
            {
                RenderEndLink(writer);
            }
            writer.ExitLayout(Style, Control.BreakAfter);
        }
        /// <include file='doc\HtmlSelectionListAdapter.uex' path='docs/doc[@for="HtmlSelectionListAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            MobileListItemCollection items      = Control.Items;
            ListSelectType           selectType = Control.SelectType;

            if (items.Count == 0 &&
                selectType != ListSelectType.ListBox &&
                selectType != ListSelectType.MultiSelectListBox)
            {
                return;
            }

            int    selectedIndex = Control.SelectedIndex;
            String renderName;

            if (Device.RequiresAttributeColonSubstitution)
            {
                renderName = Control.UniqueID.Replace(':', ',');
            }
            else
            {
                renderName = Control.UniqueID;
            }

            switch (selectType)
            {
            case ListSelectType.DropDown:
            case ListSelectType.ListBox:
            case ListSelectType.MultiSelectListBox:

                if (items.Count == 0 && !Device.CanRenderEmptySelects)
                {
                    break;
                }

                writer.EnterLayout(Style);
                writer.WriteBeginTag("select");

                if (selectType == ListSelectType.MultiSelectListBox)
                {
                    writer.Write(" multiple");
                }

                if (selectType == ListSelectType.ListBox || selectType == ListSelectType.MultiSelectListBox)
                {
                    writer.WriteAttribute("size", Control.Rows.ToString(CultureInfo.InvariantCulture));
                }

                writer.WriteAttribute("name", renderName);
                writer.Write(">");

                for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                {
                    MobileListItem item = items[itemIndex];
                    writer.WriteBeginTag("option");
                    WriteItemValueAttribute(writer, itemIndex, item.Value);
                    if (item.Selected && (Control.IsMultiSelect || itemIndex == selectedIndex))
                    {
                        writer.Write(" selected>");
                    }
                    else
                    {
                        writer.Write(">");
                    }
                    writer.WriteEncodedText(item.Text);
                    writer.WriteLine("");
                }
                writer.Write("</select>");

                if (Device.HidesRightAlignedMultiselectScrollbars &&
                    selectType == ListSelectType.MultiSelectListBox)
                {
                    // nested if for perf
                    if ((Alignment)Style[Style.AlignmentKey, true] == Alignment.Right)
                    {
                        writer.Write("&nbsp;&nbsp;&nbsp;&nbsp;");
                    }
                }
                writer.WriteLine("");

                if (!Page.DesignMode)
                {
                    writer.ExitLayout(Style, Control.BreakAfter);
                }
                else
                {
                    writer.ExitLayout(Style, false);
                }
                break;

            case ListSelectType.Radio:
            case ListSelectType.CheckBox:

                String selectTypeString =
                    (selectType == ListSelectType.Radio) ?
                    "radio" :
                    "checkbox";
                Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
                if (!Device.Tables || alignment == Alignment.Left || alignment == Alignment.NotSet)
                {
                    writer.EnterStyle(Style);
                    bool breakAfter = false;
                    for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                    {
                        if (breakAfter)
                        {
                            writer.WriteBreak();
                        }
                        MobileListItem item = items[itemIndex];

                        writer.WriteBeginTag("input");
                        writer.WriteAttribute("type", selectTypeString);
                        writer.WriteAttribute("name", renderName);
                        WriteItemValueAttribute(writer, itemIndex, item.Value);
                        if (item.Selected &&
                            (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                            Device.SupportsUncheck)
                        {
                            writer.Write(" checked>");
                        }
                        else
                        {
                            writer.Write(">");
                        }
                        writer.WriteEncodedText(item.Text);
                        breakAfter = true;
                    }
                    writer.ExitStyle(Style, Control.BreakAfter);
                }
                else     // Device supports tables and alignment is non default.
                {
                    Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true];
                    bool     nowrap   = (wrapping == Wrapping.NoWrap);

                    writer.EnterLayout(Style);
                    writer.WriteFullBeginTag("table");
                    writer.BeginStyleContext();
                    for (int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                    {
                        MobileListItem item = items[itemIndex];
                        writer.WriteFullBeginTag("tr");
                        writer.WriteBeginTag("td");
                        if (nowrap)
                        {
                            writer.WriteAttribute("nowrap", "true");
                        }
                        writer.Write(">");

                        writer.WriteBeginTag("input");
                        writer.WriteAttribute("type", selectTypeString);
                        writer.WriteAttribute("name", renderName);
                        WriteItemValueAttribute(writer, itemIndex, item.Value);
                        if (item.Selected &&
                            (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                            Device.SupportsUncheck)
                        {
                            writer.Write(" checked>");
                        }
                        else
                        {
                            writer.Write(">");
                        }

                        writer.MarkStyleContext();
                        writer.EnterFormat(Style);
                        writer.WriteEncodedText(item.Text);
                        writer.ExitFormat(Style);
                        writer.UnMarkStyleContext();
                        writer.WriteEndTag("td");
                        writer.WriteEndTag("tr");
                    }
                    writer.WriteEndTag("table");
                    writer.EndStyleContext();
                    writer.ExitFormat(Style, Control.BreakAfter);
                }
                break;
            }
        }
        /// <include file='doc\HtmlSelectionListAdapter.uex' path='docs/doc[@for="HtmlSelectionListAdapter.Render"]/*' />
        public override void Render(HtmlMobileTextWriter writer)
        {
            MobileListItemCollection items = Control.Items;
            ListSelectType selectType = Control.SelectType;

            if (items.Count == 0 && 
                selectType != ListSelectType.ListBox && 
                selectType != ListSelectType.MultiSelectListBox)
            {
                return;
            }
            
            int selectedIndex = Control.SelectedIndex;
            String renderName;
            if(Device.RequiresAttributeColonSubstitution)
            {
                renderName = Control.UniqueID.Replace(':', ',');
            }
            else
            {
                renderName = Control.UniqueID;
            }

            switch(selectType)
            {
                case ListSelectType.DropDown:
                case ListSelectType.ListBox:
                case ListSelectType.MultiSelectListBox:

                    if (items.Count == 0 && !Device.CanRenderEmptySelects)
                    {
                        break;
                    }

                    writer.EnterLayout(Style);
                    writer.WriteBeginTag("select");

                    if (selectType == ListSelectType.MultiSelectListBox)
                    {
                        writer.Write(" multiple");
                    }

                    if (selectType == ListSelectType.ListBox || selectType == ListSelectType.MultiSelectListBox)
                    {
                        writer.WriteAttribute("size", Control.Rows.ToString(CultureInfo.InvariantCulture));
                    }

                    writer.WriteAttribute("name", renderName);
                    writer.Write(">");

                    for(int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                    {
                        MobileListItem item = items[itemIndex];
                        writer.WriteBeginTag("option");
                        WriteItemValueAttribute(writer, itemIndex, item.Value);
                        if (item.Selected && (Control.IsMultiSelect || itemIndex == selectedIndex))
                        {
                            writer.Write(" selected>");
                        }
                        else
                        {
                            writer.Write(">");
                        }
                        writer.WriteEncodedText(item.Text);
                        writer.WriteLine("");
                    }
                    writer.Write("</select>");
            
                    if(Device.HidesRightAlignedMultiselectScrollbars &&
                        selectType == ListSelectType.MultiSelectListBox)
                    {
                        // nested if for perf
                        if((Alignment)Style[Style.AlignmentKey, true] == Alignment.Right)
                        {                                                
                            writer.Write("&nbsp;&nbsp;&nbsp;&nbsp;");
                        }
                    }
                    writer.WriteLine("");
                    
                    if (!Page.DesignMode)
                    {
                        writer.ExitLayout(Style, Control.BreakAfter);
                    }
                    else
                    {
                        writer.ExitLayout(Style, false);
                    }
                    break;

                case ListSelectType.Radio:
                case ListSelectType.CheckBox:

                    String selectTypeString =
                        (selectType == ListSelectType.Radio) ?
                        "radio" :
                        "checkbox";
                    Alignment alignment = (Alignment)Style[Style.AlignmentKey, true];
                    if(!Device.Tables || alignment == Alignment.Left || alignment == Alignment.NotSet)
                    {
                        writer.EnterStyle(Style);
                        bool breakAfter = false;
                        for(int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                        {
                            if(breakAfter)
                            {
                                writer.WriteBreak();
                            }
                            MobileListItem item = items[itemIndex];

                            writer.WriteBeginTag("input");
                            writer.WriteAttribute("type", selectTypeString);
                            writer.WriteAttribute("name", renderName);
                            WriteItemValueAttribute(writer, itemIndex, item.Value);
                            if (item.Selected && 
                                (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                                Device.SupportsUncheck)
                            {
                                writer.Write(" checked>");
                            }
                            else
                            {
                                writer.Write(">");
                            }
                            writer.WriteEncodedText(item.Text);
                            breakAfter = true;
                        }
                        writer.ExitStyle(Style, Control.BreakAfter);
                    }
                    else // Device supports tables and alignment is non default.
                    {
                        Wrapping  wrapping  = (Wrapping) Style[Style.WrappingKey , true];
                        bool nowrap = (wrapping == Wrapping.NoWrap);

                        writer.EnterLayout(Style);
                        writer.WriteFullBeginTag("table");
                        writer.BeginStyleContext();
                        for(int itemIndex = 0; itemIndex < items.Count; itemIndex++)
                        {
                            MobileListItem item = items[itemIndex];
                            writer.WriteFullBeginTag("tr");
                            writer.WriteBeginTag("td");
                            if(nowrap)
                            {
                                writer.WriteAttribute("nowrap","true");
                            }
                            writer.Write(">");

                            writer.WriteBeginTag("input");
                            writer.WriteAttribute("type", selectTypeString);
                            writer.WriteAttribute("name", renderName);
                            WriteItemValueAttribute(writer, itemIndex, item.Value);
                            if (item.Selected && 
                                (Control.IsMultiSelect || itemIndex == selectedIndex) &&
                                Device.SupportsUncheck)
                            {
                                writer.Write(" checked>");
                            }
                            else
                            {
                                writer.Write(">");
                            }

                            writer.MarkStyleContext();
                            writer.EnterFormat(Style);
                            writer.WriteEncodedText(item.Text);
                            writer.ExitFormat(Style);
                            writer.UnMarkStyleContext();
                            writer.WriteEndTag("td");
                            writer.WriteEndTag("tr");
                        }
                        writer.WriteEndTag("table");
                        writer.EndStyleContext();
                        writer.ExitFormat(Style, Control.BreakAfter);
                    }
                break;
            }
        }