/// <include file='doc\XhtmlBasicListAdapter.uex' path='docs/doc[@for="XhtmlListAdapter.RenderList"]/*' /> protected virtual void RenderList(XhtmlMobileTextWriter writer) { MobileListItemCollection items = Control.Items; if (items.Count == 0) { return; } ListDecoration decoration = Control.Decoration; // Review: Consider replacing switch. switch (decoration) { case ListDecoration.Bulleted: RenderBulletedList(writer); break; case ListDecoration.Numbered: RenderNumberedList(writer); break; default: if (!Device.Tables) { RenderUndecoratedList(writer); return; } RenderTableList(writer); break; } }
private void RenderListItem(XhtmlMobileTextWriter writer, MobileListItem item) { String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute); String cssClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute); if (Control.ItemsAsLinks) { RenderBeginLink(writer, item.Value, accessKey, Style, cssClass); writer.WriteEncodedText(item.Text); RenderEndLink(writer); } else if (Control.HasItemCommandHandler) { RenderPostBackEventAsAnchor(writer, item.Index.ToString(CultureInfo.InvariantCulture) /*event argument*/, item.Text /*link text*/, accessKey, Style, cssClass); } else { writer.WriteEncodedText(item.Text); } }
/// <include file='doc\XhtmlBasicValidatorAdapter.uex' path='docs/doc[@for="XhtmlValidatorAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { if (!Control.IsValid && Control.Display != WebControls.ValidatorDisplay.None) { ConditionalEnterStyle(writer, Style); ConditionalRenderOpeningSpanElement(writer); writer.WritePendingBreak(); String controlText = Control.Text; String controlErrorMessage = Control.ErrorMessage; if (controlText != null & controlText.Length > 0) { // ConditionalClearCachedEndTag() is for a device special case. ConditionalClearCachedEndTag(writer, Control.Text); writer.WriteEncodedText(Control.Text); } else if (controlErrorMessage != null && controlErrorMessage.Length > 0) { ConditionalClearCachedEndTag(writer, Control.ErrorMessage); writer.WriteEncodedText(Control.ErrorMessage); } // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle. // ConditionalExitStyle may render a block element and clear the pending break. ConditionalSetPendingBreak(writer); ConditionalRenderClosingSpanElement(writer); ConditionalExitStyle(writer, Style); } }
/// <include file='doc\XhtmlBasicListAdapter.uex' path='docs/doc[@for="XhtmlListAdapter.RenderList"]/*' /> protected virtual void RenderList (XhtmlMobileTextWriter writer) { MobileListItemCollection items = Control.Items; if (items.Count == 0) { return; } ListDecoration decoration = Control.Decoration; // Review: Consider replacing switch. switch (decoration) { case ListDecoration.Bulleted: RenderBulletedList (writer); break; case ListDecoration.Numbered: RenderNumberedList (writer); break; default: if (!Device.Tables) { RenderUndecoratedList(writer); return; } RenderTableList (writer); break; } }
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ClearPendingBreakIfDeviceBreaksOnBlockLevel"]/*' /> protected virtual void ClearPendingBreakIfDeviceBreaksOnBlockLevel(XhtmlMobileTextWriter writer) { if ((String)Device[XhtmlConstants.BreaksOnBlockElements] != "false") { writer.ClearPendingBreak(); } }
/// <include file='doc\XhtmlBasicTextViewAdapter.uex' path='docs/doc[@for="XhtmlTextViewAdapter.RenderElement"]/*' /> public void RenderElement(XhtmlMobileTextWriter writer, int index, int beginSubstring, int endSubstring) { TextViewElement element = Control.GetElement(index); writer.WritePendingBreak(); if (endSubstring == -1) { endSubstring = element.Text.Length; } String text = element.Text; if (beginSubstring > 0 || endSubstring < text.Length) { text = text.Substring(beginSubstring, endSubstring - beginSubstring); } BooleanOption prevBold = Style.Font.Bold; BooleanOption prevItalic = Style.Font.Italic; if (element.IsBold) { Style.Font.Bold = BooleanOption.True; } if (element.IsItalic) { Style.Font.Italic = BooleanOption.True; } ConditionalEnterStyle(writer, Style); if (element.Url != null) { RenderBeginLink(writer, element.Url); writer.WriteEncodedText(text); RenderEndLink(writer); } else { writer.WriteEncodedText(text); } if (element.BreakAfter) { writer.SetPendingBreak(); } ConditionalExitStyle(writer, Style); Style.Font.Bold = prevBold; Style.Font.Italic = prevItalic; }
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderBeginLink"]/*' /> protected virtual void RenderBeginLink(XhtmlMobileTextWriter writer, String target, String accessKey, Style style, String cssClass, String title) { writer.WriteBeginTag("a"); writer.Write(" href=\""); RenderHrefValue(writer, target); writer.Write("\""); if (accessKey != null && accessKey.Length > 0) { writer.WriteAttribute("accesskey", accessKey, true); } if (CssLocation != StyleSheetLocation.PhysicalFile) { String className = writer.GetCssFormatClassName(style); if (className != null) { writer.WriteAttribute("class", className); } } else if (cssClass != null && cssClass.Length > 0) { writer.WriteAttribute("class", cssClass, true /* encode */); } if (title != null && title.Length > 0) { writer.WriteAttribute("title", title, true /* encode */); } writer.WriteLine(">"); }
// For Style/CssClass args, see ASURT 144034 /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderPostBackEventAsAnchor2"]/*' /> protected virtual void RenderPostBackEventAsAnchor( XhtmlMobileTextWriter writer, String argument, String linkText, String accessKey, Style style, String cssClass) { writer.WriteBeginTag("a"); writer.Write(" href=\""); PageAdapter.RenderUrlPostBackEvent(writer, Control.UniqueID /* target */, argument); writer.Write("\" "); if (accessKey != null && accessKey.Length > 0) { writer.WriteAttribute("accesskey", accessKey); } if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") { if (CssLocation != StyleSheetLocation.PhysicalFile) { String className = writer.GetCssFormatClassName(style); if (className != null) { writer.WriteAttribute("class", className); } } else if (cssClass != null && cssClass.Length > 0) { writer.WriteAttribute("class", cssClass, true /* encode */); } } writer.Write(">"); writer.WriteEncodedText(linkText); writer.WriteEndTag("a"); }
/// <include file='doc\XhtmlBasicSelectionListAdapter.uex' path='docs/doc[@for="XhtmlSelectionListAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { // Assumption: XhtmlBasic devices all support tables (conforming to spec). if (Control.Items.Count == 0) { return; } if ((String)Device[XhtmlConstants.RequiresOnEnterForward] == "true") { AddOnEnterForward(writer); } int selectedIndex = Control.SelectedIndex; switch (Control.SelectType) { case ListSelectType.DropDown: case ListSelectType.ListBox: case ListSelectType.MultiSelectListBox: RenderSelectElement(writer); break; case ListSelectType.Radio: case ListSelectType.CheckBox: RenderInputElementSet(writer); break; } }
// Required for a very rare device case where <select> cannot follow <table>. /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalClearCachedEndTag"]/*' /> protected virtual void ConditionalClearCachedEndTag(XhtmlMobileTextWriter writer, String s) { if (s != null && s.Length > 0) { writer.ClearCachedEndTag(); } }
private void ConditionalExitPagerSpan(XhtmlMobileTextWriter writer) { if (_pagerCssSpanWritten) { writer.WriteEndTag("span"); } }
private void RenderChildren(XhtmlMobileTextWriter writer) { if (SecondaryUIControl != null) { RenderSecondaryUI(writer); return; } bool pagerRendered = false; if (Control.HasControls()) { foreach (Control child in Control.Controls) { if (Control.Footer == child) { RenderPager(writer); pagerRendered = true; } child.RenderControl(writer); } } if (!pagerRendered) { RenderPager(writer); } }
/// <include file='doc\XhtmlBasicSelectionListAdapter.uex' path='docs/doc[@for="XhtmlSelectionListAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { // Assumption: XhtmlBasic devices all support tables (conforming to spec). if (Control.Items.Count == 0) { return; } if ((String) Device[XhtmlConstants.RequiresOnEnterForward] == "true") { AddOnEnterForward(writer); } int selectedIndex = Control.SelectedIndex; switch(Control.SelectType) { case ListSelectType.DropDown: case ListSelectType.ListBox: case ListSelectType.MultiSelectListBox: RenderSelectElement (writer); break; case ListSelectType.Radio: case ListSelectType.CheckBox: RenderInputElementSet (writer); break; } }
private void RenderPostBackHeader(XhtmlMobileTextWriter writer) { bool postBack = Page.ActiveForm.Action.Length == 0; RenderPageState(writer); if (!postBack) { writer.WriteHiddenField(PageAdapter.EventSourceKey, XhtmlConstants.PostedFromOtherFile); } else if (Page.ClientViewState == null) { // The empty event source variable is used to identify a // postback request. Value attribute is not needed, and some // devices do not allow empty string value attributes. if ((String)Device["requiresHiddenFieldValues"] != "true") { writer.WriteHiddenField(PageAdapter.EventSourceKey); } else { // Placeholder value is never used, just needed for some devices. writer.WriteHiddenField(PageAdapter.EventSourceKey, PageAdapter.EventSourceKey); } } RenderHiddenVariables(writer); }
private void RenderOpeningBodyElement(XhtmlMobileTextWriter writer) { Form activeForm = Page.ActiveForm; Style formStyle = ((ControlAdapter)activeForm.Adapter).Style; if (CssLocation == StyleSheetLocation.PhysicalFile) { String cssClass = (String)activeForm.CustomAttributes[XhtmlConstants.CssClassCustomAttribute]; writer.WriteBeginTag("body"); if (cssClass != null && (String)Device["supportsBodyClassAttribute"] != "false") { writer.WriteAttribute("class", cssClass, true /* encode */); writer.PushPhysicalCssClass(cssClass); _pushedCssClassForBody = true; } writer.Write(">"); } else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" && (String)Device[XhtmlConstants.SupportsBodyClassAttribute] != "false") { writer.EnterStyle(formStyle, "body"); } else { writer.WriteFullBeginTag("body"); if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" && (String)Device[XhtmlConstants.SupportsBodyClassAttribute] == "false") { writer.SetBodyStyle(formStyle); } } }
private void RenderListViewTableHeader(XhtmlMobileTextWriter writer, int fieldCount, int[] fieldIndices, bool itemRequiresMoreButton) { String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); if (labelClass == null || labelClass.Length == 0) { labelClass = cssClass; } writer.WriteLine("<tr>"); for (int field = 0; field < fieldCount; field++) { writer.WriteBeginTag("td"); if (CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0) { writer.WriteAttribute("class", labelClass, true); } writer.Write(">"); Style labelStyle = Control.LabelStyle; ConditionalEnterStyle(writer, labelStyle); writer.WriteEncodedText(Control.AllFields[fieldIndices[field]].Title); ConditionalExitStyle(writer, labelStyle); writer.Write("</td>"); } if (itemRequiresMoreButton) { writer.WriteLine("<td/>"); } writer.WriteLine(); writer.WriteLine("</tr>"); }
/// <include file='doc\XhtmlBasicObjectListAdapter.uex' path='docs/doc[@for="XhtmlObjectListAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { if (Control.ViewMode == ObjectListViewMode.List) { if (Control.HasControls()) { ConditionalRenderOpeningDivElement(writer); RenderChildren(writer); ConditionalRenderClosingDivElement(writer); } else { RenderItemsList(writer); } } else { if (Control.Selection.HasControls()) { ConditionalRenderOpeningDivElement(writer); Control.Selection.RenderChildren(writer); ConditionalRenderClosingDivElement(writer); } else { RenderItemDetails(writer, Control.Selection); } // Review: The HTML case calls FormAdapter.DisablePager, but // this seems unnecessary, since the pager is not rendered in the secondary ui case anyway. } }
/// <include file='doc\XhtmlBasicTextViewAdapter.uex' path='docs/doc[@for="XhtmlTextViewAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { int beginElement = Control.FirstVisibleElementIndex; int beginOffset = Control.FirstVisibleElementOffset; int endElement = Control.LastVisibleElementIndex; int endOffset = Control.LastVisibleElementOffset; // ConditionalClearCachedEndTag() is for a device special case. ConditionalClearCachedEndTag(writer, Control.Text); ConditionalEnterStyle(writer, Style); ConditionalRenderOpeningSpanElement(writer); writer.WritePendingBreak(); for(int i = beginElement; i <= endElement; i++) { int begin = (i == beginElement) ? beginOffset : 0; int end; if (i == endElement) { if (endOffset <= begin) { break; } end = endOffset; } else { end = -1; } RenderElement(writer, i, begin, end); } // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle. // ConditionalExitStyle may render a block element and clear the pending break. ConditionalSetPendingBreak(writer); ConditionalRenderClosingSpanElement(writer); ConditionalExitStyle(writer, Style); }
// Render opening <div class=...> in case the stylesheet location has been specified as a physical file. /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderOpeningDivElement"]/*' /> protected virtual void ConditionalRenderOpeningDivElement(XhtmlMobileTextWriter writer) { if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] == "true") { return; } String classAttribute = (String)Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute]; if (CssLocation == StyleSheetLocation.PhysicalFile) { writer.WriteLine(); if ((String)Device["usePOverDiv"] == "true") { writer.WriteBeginTag("p"); } else { writer.WriteBeginTag("div"); } if (classAttribute != null && classAttribute.Length > 0 && writer.DiffersFromCurrentPhysicalCssClass(classAttribute)) { writer.WriteAttribute("class", classAttribute, true); writer.PushPhysicalCssClass(classAttribute); Debug.Assert(!_physicalCssClassPushed, "These calls should not be nested."); _physicalCssClassPushed = true; } writer.Write(">"); } }
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalClearPendingBreak"]/*' /> protected virtual void ConditionalClearPendingBreak(XhtmlMobileTextWriter writer) { if ((String)Device[XhtmlConstants.BreaksOnInlineElements] == "true") { writer.ClearPendingBreak(); } }
private void ConditionalRenderLinkElement(XhtmlMobileTextWriter writer) { if (DoesDeviceRequireCssSuppression()) { return; } String cssLocation = (String)Page.ActiveForm.CustomAttributes[XhtmlConstants.StyleSheetLocationCustomAttribute]; if (cssLocation != null && cssLocation.Length != 0) { writer.WriteBeginTag("link"); writer.WriteAttribute("type", "text/css"); writer.WriteAttribute("rel", "stylesheet"); writer.WriteAttribute("href", cssLocation, true); writer.WriteLine("/>"); } else if (!writer.IsStyleSheetEmpty() && CssLocation != StyleSheetLocation.Internal) { writer.WriteLine(); writer.WriteBeginTag("link"); writer.WriteAttribute("type", "text/css"); writer.WriteAttribute("rel", "stylesheet"); String queryStringValue = GetCssQueryStringValue(writer); writer.Write(" href=\"" + XhtmlConstants.CssMappedFileName + "?" + XhtmlConstants.CssQueryStringName + "=" + queryStringValue + "\"/>"); writer.WriteLine(); } }
private void AddOnEnterForward(XhtmlMobileTextWriter writer) { if (Control.SelectType == ListSelectType.CheckBox) { // ASURT 142732 writer.AddOnEnterForwardSetVar(Control.UniqueID); return; } bool firstIndex = true; StringBuilder builder = new StringBuilder(); for (int i = 0; i < Control.Items.Count; i++) { if (Control.Items[i].Selected) { if (!firstIndex) { builder.Append(";"); } builder.Append(i.ToString(CultureInfo.InvariantCulture)); firstIndex = false; } } writer.AddOnEnterForwardSetVar(Control.UniqueID, builder.ToString()); }
///////////////////////////////////////////////////////////////////////// // SPECIALIZED UTILITY METHODS FOR LIST SELECTIONLIST OBJECTLIST ///////////////////////////////////////////////////////////////////////// // tagname can be any of table, ul, ol. See the list adapters for examples. /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderOpeningListTag"]/*' /> protected virtual void RenderOpeningListTag(XhtmlMobileTextWriter writer, String tagName) { String classAttribute = (String)Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute]; if (CssLocation == StyleSheetLocation.PhysicalFile && (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") { writer.WritePendingBreak(); writer.WriteBeginTag(tagName); if (classAttribute != null && classAttribute.Length > 0 && writer.DiffersFromCurrentPhysicalCssClass(classAttribute)) { writer.WriteAttribute("class", classAttribute, true); writer.PushPhysicalCssClass(classAttribute); Debug.Assert(!_physicalCssClassPushed, "These calls should not be nested."); _physicalCssClassPushed = true; } writer.Write(">"); } else if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") { writer.WritePendingBreak(); StyleFilter filter = writer.CurrentStyleClass.GetFilter(Style); writer.EnterStyle(new XhtmlFormatStyleClass(Style, filter), tagName); } else { writer.WritePendingBreak(); writer.WriteFullBeginTag(tagName); } }
// For convenience in extensibility -not used internally. The overload with style and cssClass args is // to be preferred. See ASURT 144034. /// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderPostBackEventAsAnchor1"]/*' /> protected virtual void RenderPostBackEventAsAnchor ( XhtmlMobileTextWriter writer, String argument, String linkText, String accessKey) { RenderPostBackEventAsAnchor(writer, argument, linkText, accessKey, null /* style */, null /* cssClass */); }
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderPostBackEventAsAnchor"]/*' /> protected virtual void RenderPostBackEventAsAnchor( XhtmlMobileTextWriter writer, String argument, String linkText) { RenderPostBackEventAsAnchor(writer, argument, linkText, null /* accessKey */, null /* style */, null /*cssClass */); }
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalPopPhysicalCssClass"]/*' /> protected virtual void ConditionalPopPhysicalCssClass(XhtmlMobileTextWriter writer) { if (_physicalCssClassPushed) { writer.PopPhysicalCssClass(); _physicalCssClassPushed = false; } }
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalSetPendingBreakAfterInline"]/*' /> protected virtual void ConditionalSetPendingBreakAfterInline(XhtmlMobileTextWriter writer) { if ((String)Device[XhtmlConstants.BreaksOnInlineElements] == "true") { return; } ConditionalSetPendingBreak(writer); }
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalSetPendingBreak"]/*' /> protected virtual void ConditionalSetPendingBreak(XhtmlMobileTextWriter writer) { MobileControl mobileControl = Control as MobileControl; if (mobileControl != null && mobileControl.BreakAfter) { writer.SetPendingBreak(); } }
// Writes the href value for RenderBeginLink, depending on whether the target is a new form on the // current page or a standard url (e.g., a new page). private void RenderHrefValue(XhtmlMobileTextWriter writer, String target) { bool appendCookielessDataDictionary = PageAdapter.PersistCookielessData && !target.StartsWith("http:", StringComparison.Ordinal) && !target.StartsWith("https:", StringComparison.Ordinal); bool queryStringWritten = false; // ASURT 144021 if (target == null || target.Length == 0) { target = Page.Response.ApplyAppPathModifier(Control.TemplateSourceDirectory); } if (target.StartsWith(Constants.FormIDPrefix, StringComparison.Ordinal)) { RenderFormNavigationHrefValue(writer, target); appendCookielessDataDictionary = false; } else { // For page adapter Control = null. if (Control != null) { target = Control.ResolveUrl(target); } // ASURT 147179 if ((String)Device["requiresAbsolutePostbackUrl"] == "true" && IsRelativeUrl(target)) { String templateSourceDirectory = Page.TemplateSourceDirectory; String prefix = writer.EncodeUrlInternal(Page.Response.ApplyAppPathModifier(Page.TemplateSourceDirectory)); if (prefix[prefix.Length - 1] != '/') { prefix = prefix + '/'; } target = prefix + target; } if ((String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false") { writer.WriteEncodedText(target); } else { writer.Write(target); } queryStringWritten = target.IndexOf('?') != -1; } if (appendCookielessDataDictionary) { RenderCookielessDataDictionaryInQueryString(writer, queryStringWritten); } }
private void RenderPageState(XhtmlMobileTextWriter writer) { String viewState = Page.ClientViewState; if (viewState != null) { writer.WriteHiddenField(MobilePage.ViewStateID, viewState); } }
// A helper function to do the common code for DataBind and // RenderChildren. private void DataBindAndRender(XhtmlMobileTextWriter writer, List list, ArrayList arr) { list.DataSource = arr; list.DataBind(); list.Visible = true; list.RenderControl(writer); }
/// <include file='doc\XhtmlBasicValidationSummaryAdapter.uex' path='docs/doc[@for="XhtmlValidationSummaryAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { String[] errorMessages = null; if (Control.Visible) { errorMessages = Control.GetErrorMessages(); } if (errorMessages != null) { ConditionalEnterStyle(writer, Style, "div"); ConditionalRenderOpeningDivElement(writer); if (Control.HeaderText.Length > 0) { // ConditionalClearCachedEndTag() is for a device special case. ConditionalClearCachedEndTag(writer, Control.HeaderText); writer.WriteEncodedText(Control.HeaderText); } ArrayList arr = new ArrayList(); foreach (String errorMessage in errorMessages) { Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages"); arr.Add(errorMessage); } _list.Decoration = ListDecoration.Bulleted; _list.DataSource = arr; _list.DataBind(); if (String.Compare(Control.FormToValidate, Control.Form.UniqueID, true, CultureInfo.CurrentCulture) != 0) { _link.NavigateUrl = Constants.FormIDPrefix + Control.FormToValidate; String controlBackLabel = Control.BackLabel; _link.Text = controlBackLabel == null || controlBackLabel.Length == 0 ? GetDefaultLabel(BackLabel) : controlBackLabel; // Summary writes its own break so last control should write one. _link.BreakAfter = false; ((IAttributeAccessor)_link).SetAttribute(XhtmlConstants.AccessKeyCustomAttribute, GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute)); } else { _link.Visible = false; // Summary writes its own break so last control should write one. _list.BreakAfter = false; } // Render the child controls to display error message list and a // link for going back to the Form that is having error RenderChildren(writer); // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle. // ConditionalExitStyle may render a block element and clear the pending break. ConditionalSetPendingBreak(writer); ConditionalRenderClosingDivElement(writer); ConditionalExitStyle(writer, Style); } }
private void RenderUndecoratedList(XhtmlMobileTextWriter writer) { String br = writer.UseDivsForBreaks ? "</div><div>" : "<br/>"; if ((string)Device["usePOverDiv"] == "true") { br = "<br/>"; } RenderListBody(writer, "", br); }
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderCustomAttribute1"]/*' /> protected virtual void ConditionalRenderCustomAttribute(XhtmlMobileTextWriter writer, String attributeName, String markupAttributeName) { String attributeValue = ((IAttributeAccessor)Control).GetAttribute(attributeName); if (attributeValue != null && attributeValue.Length > 0) { writer.WriteAttribute(markupAttributeName, attributeValue, true); } }
/// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter.RenderAsHiddenInputField"]/*' /> protected override void RenderAsHiddenInputField(XhtmlMobileTextWriter writer) { // Optimization - if viewstate is enabled for this control, and the // postback returns to this page, we just let it do the trick. if (Control.Form.Action.Length > 0 || (!IsViewStateEnabled() && Control.Text != _staticValue)) { writer.WriteHiddenField(Control.UniqueID, Control.Text); } }
/// <include file='doc\XhtmlBasicPanelAdapter.uex' path='docs/doc[@for="XhtmlPanelAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { if (Control.Content != null) { Control.Content.RenderControl(writer); } else { ConditionalEnterStyle(writer, Style); ConditionalRenderOpeningDivElement(writer); RenderChildren(writer); ConditionalSetPendingBreak(writer); ConditionalRenderClosingDivElement(writer); ConditionalExitStyle(writer, Style); } }
/// <include file='doc\XhtmlBasicLiteralTextAdapter.uex' path='docs/doc[@for="XhtmlLiteralTextAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { // ConditionalClearCachedEndTag() is for a device special case. ConditionalClearCachedEndTag(writer, Control.Text); String text = Control.PagedText; ConditionalEnterStyle(writer, Style); ConditionalRenderOpeningSpanElement(writer); writer.WritePendingBreak(); writer.WriteEncodedText(text); // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle. // ConditionalExitStyle may render a block element and clear the pending break. ConditionalSetPendingBreak(writer); ConditionalRenderClosingSpanElement(writer); ConditionalExitStyle(writer, Style); }
/// <include file='doc\XhtmlBasicValidationSummaryAdapter.uex' path='docs/doc[@for="XhtmlValidationSummaryAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { String[] errorMessages = null; if (Control.Visible) { errorMessages = Control.GetErrorMessages(); } if (errorMessages != null) { ConditionalEnterStyle(writer, Style, "div"); ConditionalRenderOpeningDivElement(writer); if (Control.HeaderText.Length > 0) { // ConditionalClearCachedEndTag() is for a device special case. ConditionalClearCachedEndTag(writer, Control.HeaderText); writer.WriteEncodedText (Control.HeaderText); } ArrayList arr = new ArrayList(); foreach (String errorMessage in errorMessages) { Debug.Assert(errorMessage != null && errorMessage.Length > 0, "Bad Error Messages"); arr.Add(errorMessage); } _list.Decoration = ListDecoration.Bulleted; _list.DataSource = arr; _list.DataBind(); if (String.Compare(Control.FormToValidate, Control.Form.UniqueID, true, CultureInfo.CurrentCulture) != 0) { _link.NavigateUrl = Constants.FormIDPrefix + Control.FormToValidate; String controlBackLabel = Control.BackLabel; _link.Text = controlBackLabel == null || controlBackLabel.Length == 0 ? GetDefaultLabel(BackLabel) : controlBackLabel; // Summary writes its own break so last control should write one. _link.BreakAfter = false; ((IAttributeAccessor)_link).SetAttribute(XhtmlConstants.AccessKeyCustomAttribute, GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute)); } else { _link.Visible = false; // Summary writes its own break so last control should write one. _list.BreakAfter = false; } // Render the child controls to display error message list and a // link for going back to the Form that is having error RenderChildren(writer); // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle. // ConditionalExitStyle may render a block element and clear the pending break. ConditionalSetPendingBreak(writer); ConditionalRenderClosingDivElement(writer); ConditionalExitStyle(writer, Style); } }
/// <include file='doc\XhtmlBasicLinkAdapter.uex' path='docs/doc[@for="XhtmlLinkAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { ConditionalClearPendingBreak(writer); ConditionalEnterStyle(writer, Style); String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute); RenderBeginLink(writer, Control.NavigateUrl, accessKey, Style, cssClass); String controlText = Control.Text; writer.WriteEncodedText(controlText == null || controlText.Length == 0 ? Control.NavigateUrl : controlText); RenderEndLink(writer); // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle. // ConditionalExitStyle may render a block element and clear the pending break. ConditionalSetPendingBreakAfterInline(writer); ConditionalExitStyle(writer, Style); }
/// <include file='doc\XhtmlBasicCommandAdapter.uex' path='docs/doc[@for="XhtmlCommandAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { // Note: Since XHTML Basic and MP do not include the script element, we ignore the // Format==Link attribute as in CHTML. ConditionalClearPendingBreak(writer); string imageUrl = Control.ImageUrl; if (imageUrl != null && imageUrl.Length > 0 && Device.SupportsImageSubmit) { RenderAsInputTypeImage(writer); } else { RenderAsInputTypeSubmit(writer); } }
/// <include file='doc\XhtmlBasicListAdapter.uex' path='docs/doc[@for="XhtmlListAdapter.Render"]/*' /> public override void Render (XhtmlMobileTextWriter writer) { if (Control.HasControls()) { ConditionalRenderOpeningDivElement(writer); RenderChildren (writer); ConditionalRenderClosingDivElement(writer); return; } if (Control.Items.Count != 0) { ClearPendingBreakIfDeviceBreaksOnBlockLevel(writer); // we are writing a block level element in all cases. } ConditionalEnterLayout(writer, Style); RenderList (writer); ConditionalExitLayout(writer, Style); }
private void RenderAsInputTypeImage(XhtmlMobileTextWriter writer) { ConditionalEnterStyle(writer, Style); writer.WriteBeginTag("input"); writer.WriteAttribute("type", "image"); writer.WriteAttribute("name", Control.UniqueID); writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true); writer.WriteAttribute("alt", Control.Text, true); ConditionalRenderClassAttribute(writer); ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute); writer.Write("/>"); // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle. // ConditionalExitStyle may render a block element and clear the pending break. ConditionalSetPendingBreakAfterInline(writer); ConditionalExitStyle(writer, Style); }
/// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { ConditionalClearPendingBreak(writer); ConditionalEnterStyle(writer, Style); ConditionalRenderOpeningSpanElement(writer); if ((String) Device[XhtmlConstants.RequiresOnEnterForward] == "true") { writer.AddOnEnterForwardSetVar(Control.UniqueID, Control.Text); } writer.WriteBeginTag("input"); writer.WriteAttribute("name", Control.UniqueID); ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute); String controlText = Control.Text; if (controlText != null && controlText.Length > 0 && !Control.Password) { writer.Write(" value=\""); writer.WriteEncodedText(controlText); writer.Write("\""); } if (Control.Size > 0) { writer.WriteAttribute("size", Control.Size.ToString(CultureInfo.InvariantCulture)); } if (Control.MaxLength > 0) { writer.WriteAttribute("maxlength", Control.MaxLength.ToString(CultureInfo.InvariantCulture)); } String requiresType = Device["requiresInputTypeAttribute"]; if (Control.Password) { writer.WriteAttribute("type", "password"); } // InvariantCulture not needed, but included for best practices. else if (requiresType != null && String.Equals(requiresType, "true", StringComparison.OrdinalIgnoreCase)) { writer.WriteAttribute("type", "text"); } writer.Write("/>"); // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle. // ConditionalExitStyle may render a block element and clear the pending break. ConditionalSetPendingBreakAfterInline(writer); ConditionalRenderClosingSpanElement(writer); ConditionalExitStyle(writer, Style); }
/// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter.RenderImage"]/*' /> protected virtual void RenderImage(XhtmlMobileTextWriter writer) { String source = Control.ImageUrl; writer.WriteBeginTag("img"); if(source != null && source.Length > 0) { source = Page.Server.UrlPathEncode(Control.ResolveUrl(source.Trim())); writer.WriteAttribute("src", source, true); writer.AddResource(source); } String alternateText = Control.AlternateText; if (alternateText == null || alternateText.Length == 0) { alternateText = " "; // ASURT 143759 and VSWhidbey 78593 } writer.WriteAttribute("alt", alternateText, true); // Review: Html adapter writes border=0 attribute, but don't need this here? writer.Write(" />"); }
/// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { string target = Control.NavigateUrl; ConditionalClearPendingBreak(writer); Style style = Style; StyleFilter filter = writer.CurrentStyleClass.GetFilter(style); if ((filter & XhtmlConstants.Layout) != 0) { ConditionalEnterLayout(writer, style); } if(target != null && target.Length > 0) { String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute); String title = GetCustomAttributeValue(XhtmlConstants.TitleCustomAttribute); RenderBeginLink(writer, target, accessKey, style, cssClass, title); } else{ ConditionalEnterFormat(writer, style); ConditionalRenderOpeningSpanElement(writer); } String controlIU = Control.ImageUrl; if(controlIU == null || controlIU.Length == 0) { writer.WriteEncodedText(Control.AlternateText); } else { RenderImage(writer); } ConditionalSetPendingBreakAfterInline(writer); if(target != null && target.Length > 0) { RenderEndLink(writer); } else { ConditionalRenderClosingSpanElement(writer); ConditionalExitFormat(writer, style); } if ((filter & XhtmlConstants.Layout) != 0) { ConditionalExitLayout(writer, style); } }
/// <include file='doc\XhtmlBasicValidatorAdapter.uex' path='docs/doc[@for="XhtmlValidatorAdapter.Render"]/*' /> public override void Render(XhtmlMobileTextWriter writer) { if (!Control.IsValid && Control.Display != WebControls.ValidatorDisplay.None) { ConditionalEnterStyle(writer, Style); ConditionalRenderOpeningSpanElement(writer); writer.WritePendingBreak(); String controlText = Control.Text; String controlErrorMessage = Control.ErrorMessage; if (controlText != null & controlText.Length > 0) { // ConditionalClearCachedEndTag() is for a device special case. ConditionalClearCachedEndTag(writer, Control.Text); writer.WriteEncodedText (Control.Text); } else if (controlErrorMessage != null && controlErrorMessage.Length > 0) { ConditionalClearCachedEndTag(writer, Control.ErrorMessage); writer.WriteEncodedText (Control.ErrorMessage); } // ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle. // ConditionalExitStyle may render a block element and clear the pending break. ConditionalSetPendingBreak(writer); ConditionalRenderClosingSpanElement(writer); ConditionalExitStyle(writer, Style); } }
// Render the details view /// <include file='doc\XhtmlBasicObjectListAdapter.uex' path='docs/doc[@for="XhtmlObjectListAdapter.RenderItemDetails"]/*' /> protected virtual void RenderItemDetails(XhtmlMobileTextWriter writer, ObjectListItem item) { if (Control.AllFields.Count == 0) { return; } if (!Device.Tables) { RenderItemDetailsWithoutTableTags(writer, item); return; } Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone(); subCommandStyleNoItalic.Font.Italic = BooleanOption.False; writer.ClearPendingBreak(); // we are writing a block level element in all cases. ConditionalEnterLayout(writer, Style); writer.WriteBeginTag ("table"); ConditionalRenderClassAttribute(writer); writer.Write(">"); writer.Write("<tr><td colspan=\"2\">"); ConditionalEnterStyle(writer, labelStyle); writer.WriteEncodedText (item[Control.LabelFieldIndex]); ConditionalExitStyle(writer, labelStyle); writer.WriteLine("</td></tr>"); Color foreColor = (Color)Style[Style.ForeColorKey, true]; RenderRule (writer, foreColor, 2); RenderItemFieldsInDetailsView (writer, item); RenderRule (writer, foreColor, 2); ConditionalPopPhysicalCssClass(writer); writer.WriteEndTag("table"); ConditionalExitLayout(writer, Style); ConditionalEnterStyle(writer, subCommandStyleNoItalic); writer.Write("[ "); ObjectListCommandCollection commands = Control.Commands; String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String subCommandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); if (subCommandClass == null || subCommandClass.Length == 0) { subCommandClass = cssClass; } foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text, null /* accessKey */, subCommandStyle, subCommandClass); writer.Write(" | "); } String controlBCT = Control.BackCommandText; String backCommandText = (controlBCT == null || controlBCT.Length == 0) ? GetDefaultLabel(BackLabel) : controlBCT; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, null /* accessKey */, subCommandStyle, subCommandClass); writer.Write(" ]"); ConditionalExitStyle(writer, subCommandStyleNoItalic); }
// Called from RenderItemDetails. (Extracted for intelligibility.) private void RenderItemFieldsInDetailsView (XhtmlMobileTextWriter writer, ObjectListItem item) { Style style = Style; IObjectListFieldCollection fields = Control.AllFields; foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write("<tr><td>"); ConditionalEnterStyle(writer, Style); writer.WriteEncodedText (field.Title); ConditionalExitStyle(writer, Style); writer.Write("</td><td>"); ConditionalEnterStyle(writer, style); writer.WriteEncodedText (item [fields.IndexOf (field)]); ConditionalExitStyle(writer, style); writer.WriteLine("</td></tr>"); } } }
private void RenderNumberedList (XhtmlMobileTextWriter writer) { RenderOpeningListTag(writer, "ol"); RenderListBody (writer, "<li>", "</li>"); RenderClosingListTag(writer, "ol"); }
private void RenderListBody (XhtmlMobileTextWriter writer, String itemPrefix, String itemSuffix) { int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; for (int i = 0; i < pageSize; i++) { MobileListItem item = Control.Items[pageStart + i]; writer.Write (itemPrefix); RenderListItem (writer, item); writer.WriteLine(itemSuffix); } }
private void RenderItemDetailsWithoutTableTags(XhtmlMobileTextWriter writer, ObjectListItem item) { if (Control.VisibleItemCount == 0) { return; } Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Style subCommandStyleNoItalic = (Style)subCommandStyle.Clone(); subCommandStyleNoItalic.Font.Italic = BooleanOption.False; ConditionalRenderOpeningDivElement(writer); String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); if (labelClass == null || labelClass.Length == 0) { labelClass = cssClass; } ConditionalEnterStyle(writer, labelStyle); bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0; if (requiresLabelClassSpan) { writer.WriteBeginTag("span"); writer.WriteAttribute("class", labelClass, true); writer.Write(">"); } writer.Write(item[Control.LabelFieldIndex]); writer.SetPendingBreak(); if (requiresLabelClassSpan) { writer.WriteEndTag("span"); } ConditionalExitStyle(writer, labelStyle); writer.WritePendingBreak(); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; ConditionalEnterStyle(writer, style); foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write(field.Title + ":"); writer.Write(" "); writer.Write(item[fieldIndex]); writer.WriteBreak(); } fieldIndex++; } ConditionalExitStyle(writer, style); String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); ConditionalEnterStyle(writer, subCommandStyleNoItalic); if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write("[ "); } ConditionalEnterStyle(writer, subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text); if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" | "); } } String controlBCT = Control.BackCommandText; String backCommandText = controlBCT == null || controlBCT.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText); ConditionalExitStyle(writer, subCommandStyle); if ((String) Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" ]"); } ConditionalExitStyle(writer, subCommandStyleNoItalic); ConditionalRenderClosingDivElement(writer); }
private void RenderTableList (XhtmlMobileTextWriter writer) { RenderOpeningListTag(writer, "table"); RenderListBody (writer, "<tr><td>", "</td></tr>"); RenderClosingListTag(writer, "table"); }
private void RenderListItem (XhtmlMobileTextWriter writer, MobileListItem item) { String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute); String cssClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute); if (Control.ItemsAsLinks) { RenderBeginLink (writer, item.Value, accessKey, Style, cssClass); writer.WriteEncodedText (item.Text); RenderEndLink (writer); } else if (Control.HasItemCommandHandler) { RenderPostBackEventAsAnchor (writer, item.Index.ToString(CultureInfo.InvariantCulture) /*event argument*/, item.Text /*link text*/, accessKey, Style, cssClass); } else { writer.WriteEncodedText (item.Text); } }
// Render the list view /// <include file='doc\XhtmlBasicObjectListAdapter.uex' path='docs/doc[@for="XhtmlObjectListAdapter.RenderItemsList"]/*' /> protected virtual void RenderItemsList(XhtmlMobileTextWriter writer) { if (Control.VisibleItemCount == 0) { return; } if (!Device.Tables) { RenderItemsListWithoutTableTags(writer); return; } int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; ObjectListItemCollection items = Control.Items; bool hasDefaultCommand = HasDefaultCommand(); bool onlyHasDefaultCommand = OnlyHasDefaultCommand(); bool requiresDetailsScreen = RequiresDetailsScreen (); bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand; bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand; int fieldCount; int[] fieldIndices; DetermineFieldIndicesAndCount (out fieldCount, out fieldIndices); Style style = this.Style; Style subCommandStyle = Control.CommandStyle; Style labelStyle = Control.LabelStyle; Color foreColor = (Color)style[Style.ForeColorKey, true]; // Note: table width is not supported in DTD (the text of the rec says it's supported; a bug in the rec). ClearPendingBreakIfDeviceBreaksOnBlockLevel(writer); // we are writing a block level element in all cases. ConditionalEnterLayout(writer, Style); RenderOpeningListTag(writer, "table"); RenderListViewTableHeader (writer, fieldCount, fieldIndices, itemRequiresMoreButton); RenderRule (writer, foreColor , fieldCount + (itemRequiresMoreButton ? 1 : 0)); for (int i = 0; i < pageSize; i++) { ObjectListItem item = items[pageStart + i]; RenderListViewItem (writer, item, fieldCount, fieldIndices, itemRequiresMoreButton, itemRequiresHyperlink); } RenderRule (writer, foreColor , fieldCount + (itemRequiresMoreButton ? 1 : 0)); RenderClosingListTag(writer, "table"); ConditionalExitLayout(writer, Style); }
private void RenderUndecoratedList (XhtmlMobileTextWriter writer) { String br = writer.UseDivsForBreaks ? "</div><div>" : "<br/>"; if((string)Device["usePOverDiv"] == "true") br = "<br/>"; RenderListBody (writer, "", br); }
private void RenderRule (XhtmlMobileTextWriter writer, Color foreColor, int columnSpan) { if (CssLocation == StyleSheetLocation.PhysicalFile || Device["requiresXhtmlCssSuppression"] == "true") { // Review: Since, if there is a physical stylesheet, we cannot know the intended foreColor, // do not render a rule. return; } writer.Write("<tr>"); Style hruleStyle = new Style(); // Rendering <td...> with background color equal to the style's forecolor renders a thin // rule with color forecolor, as intended. hruleStyle[Style.BackColorKey] = foreColor == Color.Empty ? Color.Black : foreColor; NameValueCollection additionalAttributes = new NameValueCollection(); additionalAttributes["colspan"] = columnSpan.ToString(CultureInfo.InvariantCulture); writer.EnterStyleInternal(hruleStyle, "td", StyleFilter.BackgroundColor, additionalAttributes); writer.ExitStyle(Style); writer.WriteEndTag("tr"); }
private void RenderListViewTableHeader (XhtmlMobileTextWriter writer, int fieldCount, int[] fieldIndices, bool itemRequiresMoreButton){ String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); if (labelClass == null || labelClass.Length == 0) { labelClass = cssClass; } writer.WriteLine("<tr>"); for (int field = 0; field < fieldCount; field++) { writer.WriteBeginTag("td"); if (CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0) { writer.WriteAttribute("class", labelClass, true); } writer.Write(">"); Style labelStyle = Control.LabelStyle; ConditionalEnterStyle(writer, labelStyle); writer.WriteEncodedText(Control.AllFields[fieldIndices[field]].Title); ConditionalExitStyle(writer, labelStyle); writer.Write("</td>"); } if (itemRequiresMoreButton) { writer.WriteLine("<td/>"); } writer.WriteLine(); writer.WriteLine("</tr>"); }
// Render a single ObjectListItem in list view. private void RenderListViewItem (XhtmlMobileTextWriter writer, ObjectListItem item, int fieldCount, int[] fieldIndices, bool itemRequiresMoreButton, bool itemRequiresHyperlink) { Style style = Style; Style subCommandStyle = Control.CommandStyle; String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute); String cssClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute); String subCommandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); if (subCommandClass == null || subCommandClass.Length == 0) { subCommandClass = cssClass; } writer.WriteLine("<tr>"); // Render fields. for (int field = 0; field < fieldCount; field++) { writer.Write("<td>"); if (field == 0 && itemRequiresHyperlink) { String eventArgument = HasDefaultCommand() ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture)); RenderPostBackEventAsAnchor(writer, eventArgument, item[fieldIndices[0]], accessKey, Style, cssClass); } else { writer.WriteEncodedText (item[fieldIndices[field]]); } writer.WriteLine("</td>"); } if (itemRequiresMoreButton) { writer.Write("<td>"); String controlMT = Control.MoreText; String moreText = (controlMT == null || controlMT.Length == 0) ? GetDefaultLabel(MoreLabel) : controlMT; RenderPostBackEventAsAnchor(writer, String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), moreText, null /*accessKey*/, subCommandStyle, subCommandClass); writer.WriteLine("</td>"); } writer.WriteLine("</tr>"); }
private void RenderItemsListWithoutTableTags(XhtmlMobileTextWriter writer) { if (Control.VisibleItemCount == 0) { return; } ConditionalRenderOpeningDivElement(writer); int startIndex = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; ObjectListItemCollection items = Control.Items; IObjectListFieldCollection allFields = Control.AllFields; int count = allFields.Count; int nextStartIndex = startIndex + pageSize; int labelFieldIndex = Control.LabelFieldIndex; Style style = this.Style; Style labelStyle = Control.LabelStyle; String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute); String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute); if (labelClass == null || labelClass.Length == 0) { labelClass = cssClass; } ConditionalEnterStyle(writer, labelStyle); bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0; if (requiresLabelClassSpan) { writer.WriteBeginTag("span"); writer.WriteAttribute("class", labelClass, true); writer.Write(">"); } writer.Write(Control.AllFields[labelFieldIndex].Title); writer.SetPendingBreak(); if (requiresLabelClassSpan) { writer.WriteEndTag("span"); } ConditionalExitStyle(writer, labelStyle); writer.WritePendingBreak(); bool hasDefaultCommand = HasDefaultCommand(); bool onlyHasDefaultCommand = OnlyHasDefaultCommand(); bool requiresDetailsScreen = !onlyHasDefaultCommand && HasCommands(); // if there is > 1 visible field, need a details screen for (int visibleFields = 0, i = 0; !requiresDetailsScreen && i < count; i++) { visibleFields += allFields[i].Visible ? 1 : 0; requiresDetailsScreen = requiresDetailsScreen || visibleFields > 1; } bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand; bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand; Style subCommandStyle = Control.CommandStyle; subCommandStyle.Alignment = style.Alignment; subCommandStyle.Wrapping = style.Wrapping; ConditionalEnterStyle(writer, style); for (int i = startIndex; i < nextStartIndex; i++) { ObjectListItem item = items[i]; String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute); String itemClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute); if (itemRequiresHyperlink) { RenderPostBackEventAsAnchor(writer, hasDefaultCommand ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), item[labelFieldIndex], accessKey, Style, cssClass); } else { bool requiresItemClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && itemClass != null && itemClass.Length > 0; if (requiresItemClassSpan) { writer.WriteBeginTag("span"); writer.WriteAttribute("class", itemClass, true); writer.Write(">"); } writer.Write(item[labelFieldIndex]); if (requiresItemClassSpan) { writer.WriteEndTag("span"); } } if (itemRequiresMoreButton) { String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute); BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; ConditionalEnterFormat(writer, subCommandStyle); if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write(" ["); } ConditionalExitFormat(writer, subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; ConditionalEnterFormat(writer, subCommandStyle); String controlMT = Control.MoreText; String moreText = (controlMT == null || controlMT.Length == 0) ? GetDefaultLabel(MoreLabel) : controlMT; RenderPostBackEventAsAnchor(writer, String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), moreText, null /*accessKey*/, subCommandStyle, commandClass); ConditionalExitFormat(writer, subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; ConditionalEnterFormat(writer, subCommandStyle); if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") { writer.Write("]"); } ConditionalExitFormat(writer, subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; } if (i < (nextStartIndex - 1)) { writer.WriteBreak(); } else { writer.SetPendingBreak(); } } ConditionalExitStyle(writer, style); ConditionalRenderClosingDivElement(writer); }