/// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.RenderPager"]/*' /> protected virtual void RenderPager(HtmlMobileTextWriter writer) { if (!_renderPager) { return; } PagerStyle pagerStyle = Control.PagerStyle; int pageCount = Control.PageCount; if (pageCount <= 1) { return; } int page = Control.CurrentPage; String text = pagerStyle.GetPageLabelText(page, pageCount); if ((page > 1) || (text.Length > 0) || (page < pageCount)) { writer.EnterStyle(pagerStyle); } if (page > 1) { RenderPagerTag(writer, page - 1, pagerStyle.GetPreviousPageText(page)); writer.Write(" "); } if (text.Length > 0) { writer.WriteEncodedText(text); writer.Write(" "); } if (page < pageCount) { RenderPagerTag(writer, page + 1, pagerStyle.GetNextPageText(page)); } if ((page > 1) || (text.Length > 0) || (page < pageCount)) { writer.ExitStyle(pagerStyle, true); } }
/// <include file='doc\HtmlListAdapter.uex' path='docs/doc[@for="HtmlListAdapter.RenderList"]/*' /> 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("<ul>"); listSuffix = "</ul>"; itemPrefix = "<li>"; itemSuffix = "</li>"; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "<br>"; } break; case ListDecoration.Numbered: if (pageStart == 0) { writer.WriteLine("<ol>"); } else { writer.Write("<ol start=\""); writer.Write(pageStart + 1); writer.WriteLine("\">"); } listSuffix = "</ol>"; itemPrefix = "<li>"; itemSuffix = "</li>"; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "<br>"; } break; default: if (Device.Tables) { listSuffix = "</table>"; Style.Wrapping = Wrapping.NotSet; writer.EnterLayout(Style); writer.WriteLine("<table>"); if (wrap == Wrapping.NoWrap) { itemPrefix = "<tr nowrap><td>"; } else { itemPrefix = "<tr><td>"; } itemSuffix = "</td></tr>"; } else { listSuffix = String.Empty; itemPrefix = String.Empty; itemSuffix = "<br>"; } 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; } }
/// <include file='doc\ChtmlSelectionListAdapter.uex' path='docs/doc[@for="ChtmlSelectionListAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { ListSelectType selectType = Control.SelectType; if (selectType == ListSelectType.MultiSelectListBox && Device.SupportsSelectMultiple == false) { // Render occurs after SaveViewState. Here we make a temp // change which is not persisted to the view state. Control.SelectType = selectType = ListSelectType.CheckBox; } if (!Device.RequiresUniqueHtmlCheckboxNames || selectType != ListSelectType.CheckBox) { base.Render(writer); } else { MobileListItemCollection items = Control.Items; if (items.Count == 0) { return; } writer.EnterStyle(Style); bool writeBreak = false; foreach (MobileListItem item in items) { int index = items.IndexOf(item); if(writeBreak) { writer.WriteBreak(); } writer.Write("<input type=\"checkbox\" name=\""); if(Device.RequiresAttributeColonSubstitution) { writer.Write(Control.UniqueID.Replace(':', ',')); } else { writer.Write(Control.UniqueID); } writer.Write(Constants.SelectionListSpecialCharacter); writer.Write(index); writer.Write("\" value=\""); if (!String.IsNullOrEmpty(Control.Form.Action)) { writer.WriteEncodedText(item.Value); } else { writer.Write(item.Index.ToString(CultureInfo.InvariantCulture)); } if (item.Selected && Device.SupportsUncheck) { writer.Write("\" checked>"); } else { writer.Write("\">"); } writer.WriteText(item.Text, true); writeBreak = true; } writer.ExitStyle(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(" "); } } 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\ChtmlSelectionListAdapter.uex' path='docs/doc[@for="ChtmlSelectionListAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { ListSelectType selectType = Control.SelectType; if (selectType == ListSelectType.MultiSelectListBox && Device.SupportsSelectMultiple == false) { // Render occurs after SaveViewState. Here we make a temp // change which is not persisted to the view state. Control.SelectType = selectType = ListSelectType.CheckBox; } if (!Device.RequiresUniqueHtmlCheckboxNames || selectType != ListSelectType.CheckBox) { base.Render(writer); } else { MobileListItemCollection items = Control.Items; if (items.Count == 0) { return; } writer.EnterStyle(Style); bool writeBreak = false; foreach (MobileListItem item in items) { int index = items.IndexOf(item); if (writeBreak) { writer.WriteBreak(); } writer.Write("<input type=\"checkbox\" name=\""); if (Device.RequiresAttributeColonSubstitution) { writer.Write(Control.UniqueID.Replace(':', ',')); } else { writer.Write(Control.UniqueID); } writer.Write(Constants.SelectionListSpecialCharacter); writer.Write(index); writer.Write("\" value=\""); if (!String.IsNullOrEmpty(Control.Form.Action)) { writer.WriteEncodedText(item.Value); } else { writer.Write(item.Index.ToString(CultureInfo.InvariantCulture)); } if (item.Selected && Device.SupportsUncheck) { writer.Write("\" checked>"); } else { writer.Write("\">"); } writer.WriteText(item.Text, true); writeBreak = true; } writer.ExitStyle(Style, Control.BreakAfter); } }
/// <include file='doc\HtmlListAdapter.uex' path='docs/doc[@for="HtmlListAdapter.RenderList"]/*' /> 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("<ul>"); listSuffix = "</ul>"; itemPrefix = "<li>"; itemSuffix = "</li>"; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "<br>"; } break; case ListDecoration.Numbered: if (pageStart == 0) { writer.WriteLine("<ol>"); } else { writer.Write("<ol start=\""); writer.Write(pageStart + 1); writer.WriteLine("\">"); } listSuffix = "</ol>"; itemPrefix = "<li>"; itemSuffix = "</li>"; if (!Device.RendersBreaksAfterHtmlLists) { listSuffix += "<br>"; } break; default: if (Device.Tables) { listSuffix = "</table>"; Style.Wrapping = Wrapping.NotSet; writer.EnterLayout(Style); writer.WriteLine("<table>"); if(wrap == Wrapping.NoWrap) { itemPrefix = "<tr nowrap><td>"; } else { itemPrefix = "<tr><td>"; } itemSuffix = "</td></tr>"; } else { listSuffix = String.Empty; itemPrefix = String.Empty; itemSuffix = "<br>"; } 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; } }
/// <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(" "); } } 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; } }