internal WriterState(HtmlMobileTextWriter writer) : base(writer) { _writer = writer; _stack = new Stack(); _current = new WriterStyle(); _tagsWritten = new Stack(); }
// Can be used by adapter that adds the custom attribute "accesskey" protected virtual void AddAccesskeyAttribute(HtmlMobileTextWriter writer) { if (Device.SupportsAccesskeyAttribute) { AddCustomAttribute(writer, "accesskey"); } }
/// <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\HtmlTextViewAdapter.uex' path='docs/doc[@for="HtmlTextViewAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { int beginElement = Control.FirstVisibleElementIndex; int beginOffset = Control.FirstVisibleElementOffset; int endElement = Control.LastVisibleElementIndex; int endOffset = Control.LastVisibleElementOffset; writer.EnterStyle(Style); 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); } writer.ExitStyle(Style, Control.BreakAfter); }
/// <include file='doc\HtmlObjectListAdapter.uex' path='docs/doc[@for="HtmlObjectListAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { if (Control.ViewMode == ObjectListViewMode.List) { if (Control.HasControls()) { RenderChildren(writer); } else { RenderItemsList(writer); } } else { if (Control.Selection.HasControls()) { Control.Selection.RenderChildren(writer); } else { RenderItemDetails(writer, Control.Selection); } FormAdapter.DisablePager(); } }
/////////////////////////////////////////////////////////////////////////// // IControlAdapter implementation /////////////////////////////////////////////////////////////////////////// public override void Render(HtmlMobileTextWriter writer) { writer.BeginResponse(); if (RequiresPragmaNoCacheHeader()) { Page.Response.AppendHeader("Pragma", "no-cache"); } if (writer.SupportsMultiPart) { // -1 means it doesn't care about forms' total weight _renderableForms = Page.ActiveForm.GetLinkedForms(-1); Debug.Assert(_renderableForms != null, "_renderableForms is null"); foreach (Form form in _renderableForms) { RenderForm(writer, form); } } else { RenderForm(writer, Page.ActiveForm); } writer.EndResponse(); }
public override void Render(HtmlMobileTextWriter writer) { writer.WriteBeginTag("div"); String width = DesignerAdapterUtil.GetWidth(Control); writer.WriteAttribute("style", "cellpadding=2px;width:" + width); Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; if (alignment != Alignment.NotSet) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write("/>"); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); //Note: Although this is an internal method of runtime, but it is still // pretty easy to achieve the same goal without using this method. Style.ApplyTo(Control.WebCalendar); base.Render(writer); ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); writer.WriteEndTag("div"); }
public virtual void RenderPostBackHeader(HtmlMobileTextWriter writer, Form form) { bool postBack = form.Action.Length == 0; RenderPageState(writer); writer.WriteHiddenField(EventSourceKey, postBack ? "" : _postedFromOtherFile); writer.WriteHiddenField(EventArgumentKey, ""); RenderHiddenVariables(writer); writer.Write("<script language=javascript><!--\r\n"); writer.Write("function __doPostBack(target, argument){\r\n"); writer.Write(" var theform = document."); writer.Write(form.ClientID); writer.Write("\r\n"); if (form.Action.Length > 0) { writer.Write(" theform.action = \"\"\r\n"); } writer.Write(" theform."); writer.Write(EventSourceKey); writer.Write(".value = target\r\n"); writer.Write(" theform."); writer.Write(EventArgumentKey); writer.Write(".value = argument\r\n"); writer.Write(" theform.submit()\r\n"); writer.Write("}\r\n"); writer.Write("// -->\r\n"); writer.Write("</script>\r\n"); }
/// <include file='doc\HtmlTextBoxAdapter.uex' path='docs/doc[@for="HtmlTextBoxAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterLayout(Style); writer.WriteBeginTag("input"); writer.WriteAttribute("name", GetRenderName()); if ((Control.Text == null || Control.Text.Length > 0) && !Control.Password) { writer.Write(" value=\""); writer.WriteText(Control.Text, true); 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)); } if (Control.Password) { writer.WriteAttribute("type", "password"); } AddAttributes(writer); writer.Write("/>"); writer.ExitLayout(Style, Control.BreakAfter); writer.InputWritten = true; }
/// <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\ChtmlImageAdapter.uex' path='docs/doc[@for="ChtmlImageAdapter.RenderImage"]/*' /> protected internal override void RenderImage(HtmlMobileTextWriter writer) { String source = Control.ImageUrl; if (source.StartsWith(Constants.SymbolProtocol, StringComparison.Ordinal) && (Device.SupportsIModeSymbols || Device.SupportsJPhoneSymbols)) { if (Device.SupportsIModeSymbols) { writer.Write("&#"); writer.Write( source.Substring(Constants.SymbolProtocol.Length)); writer.Write(";"); } else { // The ImageUrl should be in the format "symbol:xyyy", // where x is group picture character (either G, E or F), // and yyy (length can vary) is the picture's character // code (in decimal). String symbolChars = source.Substring( Constants.SymbolProtocol.Length); char code = DecimalStringToChar(symbolChars.Substring(1)); writer.Write("\u001B$"); writer.Write(Char.ToUpper(symbolChars[0], CultureInfo.InvariantCulture)); writer.Write(code); writer.Write('\u000F'); } } else { base.RenderImage(writer); } }
/// <include file='doc\ChtmlFormAdapter.uex' path='docs/doc[@for="ChtmlFormAdapter.RenderExtraHeadElements"]/*' /> protected override bool RenderExtraHeadElements(HtmlMobileTextWriter writer) { bool result = false; String metaTagName = Device.RequiredMetaTagNameValue; if (metaTagName != null) { if (writer != null) { writer.Write("<meta NAME=\"" + metaTagName + "\" CONTENT=\"True\">\r\n"); } result = true; } String charset = Page.Response.Charset; if (Device.RequiresContentTypeMetaTag && charset != null && charset.Length > 0) { if (writer != null) { writer.Write(String.Format(CultureInfo.InvariantCulture, _contentTypeMetaTag, Device.PreferredRenderingMime, charset)); } result = true; } return(result); }
/// <include file='doc\HtmlTextBoxAdapter.uex' path='docs/doc[@for="HtmlTextBoxAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterLayout(Style); writer.WriteBeginTag("input"); writer.WriteAttribute("name", GetRenderName()); if ((Control.Text == null || Control.Text.Length > 0) && !Control.Password) { writer.Write(" value=\""); writer.WriteText(Control.Text, true); 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)); } if (Control.Password) { writer.WriteAttribute("type", "password"); } AddAttributes(writer); writer.Write("/>"); writer.ExitLayout(Style, Control.BreakAfter); writer.InputWritten = true; }
/// <include file='doc\HtmlObjectListAdapter.uex' path='docs/doc[@for="HtmlObjectListAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { if (Control.ViewMode == ObjectListViewMode.List) { if (Control.HasControls()) { RenderChildren(writer); } else { RenderItemsList(writer); } } else { if (Control.Selection.HasControls()) { Control.Selection.RenderChildren(writer); } else { RenderItemDetails(writer, Control.Selection); } FormAdapter.DisablePager(); } }
/// <include file='doc\HtmlTextViewAdapter.uex' path='docs/doc[@for="HtmlTextViewAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { int beginElement = Control.FirstVisibleElementIndex; int beginOffset = Control.FirstVisibleElementOffset; int endElement = Control.LastVisibleElementIndex; int endOffset = Control.LastVisibleElementOffset; writer.EnterStyle(Style); 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); } writer.ExitStyle(Style, Control.BreakAfter); }
// calls the more specific render methods /// <include file='doc\HtmlLiteralTextAdapter.uex' path='docs/doc[@for="HtmlLiteralTextAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { String text = Control.PagedText; writer.EnterStyle(Style); writer.WriteText(text, true); writer.ExitStyle(Style, Control.BreakAfter); }
/// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.RenderPagerTag"]/*' /> protected internal virtual void RenderPagerTag( HtmlMobileTextWriter writer, int pageToNavigate, String text) { RenderPostBackEventAsAnchor(writer, pageToNavigate.ToString(CultureInfo.InvariantCulture), text); }
// calls the more specific render methods /// <include file='doc\HtmlLiteralTextAdapter.uex' path='docs/doc[@for="HtmlLiteralTextAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { String text = Control.PagedText; writer.EnterStyle(Style); writer.WriteText(text, true); writer.ExitStyle(Style, Control.BreakAfter); }
private void RenderRule(HtmlMobileTextWriter writer, Color foreColor, int columnSpan) { writer.Write("<tr><td colspan="); writer.Write(columnSpan.ToString(CultureInfo.InvariantCulture)); writer.Write(" bgcolor=\""); writer.Write((foreColor != Color.Empty) ? ColorTranslator.ToHtml(foreColor) : "#000000"); writer.Write("\"></td></tr>"); }
public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); RenderBeginLink(writer, Control.NavigateUrl); writer.WriteText((Control.Text == String.Empty) ? Control.NavigateUrl : Control.Text, true); RenderEndLink(writer); writer.ExitStyle(Style, Control.BreakAfter); }
private void RenderRule(HtmlMobileTextWriter writer, Color foreColor, int columnSpan) { writer.Write("<tr><td colspan="); writer.Write(columnSpan.ToString()); writer.Write(" bgcolor=\""); writer.Write((foreColor == Color.Empty) ? "#000000" : ColorTranslator.ToHtml(foreColor)); writer.Write("\"></td></tr>"); }
// Return true if actually wrote any head elements. If called with // null, this returns whether head elements would be written if called // with a real writer. /// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.RenderExtraHeadElements"]/*' /> protected virtual bool RenderExtraHeadElements(HtmlMobileTextWriter writer) { bool result = false; String metaTagName = Device.RequiredMetaTagNameValue; if (metaTagName != null) { if (writer != null) { writer.Write("<meta NAME=\"" + metaTagName + "\" CONTENT=\"True\">\r\n"); } result = true; } String charset = Page.Response.Charset; if (Device.RequiresContentTypeMetaTag && charset != null && charset.Length > 0) { if (writer != null) { writer.Write(String.Format(CultureInfo.InvariantCulture, _contentTypeMetaTag, Device.PreferredRenderingMime, charset)); } result = true; } Form form = this.Control as Form; if (writer == null) { if ((form != null) && (form.Script != null)) { result = true; } } else if ((form != null) && (form.Script != null)) { foreach (Control childControl in form.Script.Controls) { LiteralControl lc = childControl as LiteralControl; if (lc != null) { writer.Write(lc.Text); } else { DataBoundLiteralControl dlc = childControl as DataBoundLiteralControl; if (dlc != null) { writer.Write(dlc.Text); } } } result = true; } return(result); }
/// <include file='doc\HtmlLinkAdapter.uex' path='docs/doc[@for="HtmlLinkAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); String navigateUrl = Control.NavigateUrl; RenderBeginLink(writer, navigateUrl); writer.WriteText(String.IsNullOrEmpty(Control.Text) ? navigateUrl : Control.Text, true); RenderEndLink(writer); writer.ExitStyle(Style, Control.BreakAfter); }
///////////////////////////////////////////////////////////////////// // IControlAdapter implementation ///////////////////////////////////////////////////////////////////// /// <include file='doc\ChtmlPageAdapter.uex' path='docs/doc[@for="ChtmlPageAdapter.RenderPostBackEvent"]/*' /> public override void RenderPostBackEvent(HtmlMobileTextWriter writer, String target, String argument) { // Since it doesn't have scripts, the CHTML adapter // only supports URL postback events. RenderUrlPostBackEvent(writer, target, argument); }
/// <include file='doc\HtmlFormAdapter.uex' path='docs/doc[@for="HtmlFormAdapter.RenderBodyTag"]/*' /> protected virtual void RenderBodyTag(HtmlMobileTextWriter writer, IDictionary attributes) { writer.WriteBeginTag("body"); foreach (DictionaryEntry entry in attributes) { writer.WriteAttribute((String)entry.Key, (String)entry.Value, true); } writer.WriteLine(">"); }
/// <include file='doc\HtmlListAdapter.uex' path='docs/doc[@for="HtmlListAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { if (Control.HasControls()) { RenderChildren(writer); return; } RenderList(writer); }
internal void RenderPageState(HtmlMobileTextWriter writer) { String viewState = Page.ClientViewState; if (viewState != null) { writer.WriteHiddenField(MobilePage.ViewStateID, viewState); } }
/// <include file='doc\HtmlListAdapter.uex' path='docs/doc[@for="HtmlListAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { if(Control.HasControls()) { RenderChildren(writer); return; } RenderList(writer); }
// A helper function to do the common code for DataBind and // RenderChildren. private void DataBindAndRender(HtmlMobileTextWriter writer, List list, ArrayList arr) { list.DataSource = arr; list.DataBind(); list.Visible = true; list.RenderControl(writer); }
private void AddCustomAttribute(HtmlMobileTextWriter writer, String attributeName) { String attributeValue = ((IAttributeAccessor)Control).GetAttribute(attributeName); if (!String.IsNullOrEmpty(attributeValue)) { writer.WriteAttribute(attributeName, attributeValue); } }
private void AddCustomAttribute(HtmlMobileTextWriter writer, String attributeName) { String attributeValue = ((IAttributeAccessor)Control).GetAttribute(attributeName); if (attributeValue != null && attributeValue != String.Empty) { writer.WriteAttribute(attributeName, attributeValue); } }
/// <include file='doc\HtmlLinkAdapter.uex' path='docs/doc[@for="HtmlLinkAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); String navigateUrl = Control.NavigateUrl; RenderBeginLink(writer, navigateUrl); writer.WriteText(String.IsNullOrEmpty(Control.Text) ? navigateUrl : Control.Text, true); RenderEndLink(writer); writer.ExitStyle(Style, Control.BreakAfter); }
public virtual void RenderPostBackEvent(HtmlMobileTextWriter writer, String target, String argument) { writer.Write("javascript:__doPostBack('"); writer.Write(target); writer.Write("','"); writer.Write(argument); writer.Write("')"); }
private void RenderPostBackEventAsAnchor(HtmlMobileTextWriter writer, string argument, string linkText, Style style) { writer.EnterFormat(style); writer.WriteBeginTag("a"); base.RenderPostBackEventAsAttribute(writer, "href", argument); writer.Write(">"); writer.WriteText(linkText, true); writer.WriteEndTag("a"); writer.ExitFormat(style); }
/// <include file='doc\HtmlTextBoxAdapter.uex' path='docs/doc[@for="HtmlTextBoxAdapter.RenderAsHiddenInputField"]/*' /> protected override void RenderAsHiddenInputField(HtmlMobileTextWriter 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); } }
public override void Render(HtmlMobileTextWriter writer) { writer.WriteBeginTag("div"); ((DesignerTextWriter)writer).WriteDesignerStyleAttributes(Control, Style); writer.Write("\">"); base.Render(writer); writer.WriteEndTag("div"); }
public override void Render(HtmlMobileTextWriter writer) { String additionalStyle; Alignment alignment = (Alignment)Style[Style.AlignmentKey, true]; Wrapping wrapping = (Wrapping)Style[Style.WrappingKey, true]; bool wrap = (wrapping == Wrapping.Wrap || wrapping == Wrapping.NotSet); String width = DesignerAdapterUtil.GetWidth(Control); ((DesignerTextWriter)writer).EnterZeroFontSizeTag(); writer.EnterLayout(Style); writer.WriteBeginTag("div"); if (!wrap) { byte templateStatus; int maxWidth = DesignerAdapterUtil.GetMaxWidthToFit(Control, out templateStatus); if (templateStatus == DesignerAdapterUtil.CONTROL_IN_TEMPLATE_EDIT) { width = maxWidth.ToString(CultureInfo.InvariantCulture) + "px"; } additionalStyle = "overflow-x:hidden;width:" + width + ";"; } else { additionalStyle = "word-wrap:break-word;width:" + width + ";"; } ((DesignerTextWriter)writer).WriteStyleAttribute(Style, additionalStyle); if (alignment != Alignment.NotSet) { writer.WriteAttribute("align", Enum.GetName(typeof(Alignment), alignment)); } writer.Write(">"); writer.WriteText(Control.HeaderText, true); writer.WriteFullBeginTag("ul"); for (int i = 1; i <= 2; i++) { writer.WriteFullBeginTag("li"); writer.Write(SR.GetString(SR.ValidationSummary_ErrorMessage, i.ToString(CultureInfo.InvariantCulture))); writer.WriteEndTag("li"); } writer.WriteEndTag("ul"); writer.WriteBeginTag("a"); writer.WriteAttribute("href", "NavigationUrl"); writer.Write(">"); writer.WriteText(String.IsNullOrEmpty(Control.BackLabel) ? GetDefaultLabel(BackLabel) : Control.BackLabel, true); writer.WriteEndTag("a"); writer.WriteEndTag("div"); writer.ExitLayout(Style); ((DesignerTextWriter)writer).ExitZeroFontSizeTag(); }
/// <include file='doc\HtmlPanelAdapter.uex' path='docs/doc[@for="HtmlPanelAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { if (Control.Content != null) { Control.Content.RenderControl(writer); } else { writer.EnterStyle(Style); RenderChildren(writer); writer.ExitStyle(Style, Control.BreakAfter); } }
/// <include file='doc\HtmlPhoneCallAdapter.uex' path='docs/doc[@for="HtmlPhoneCallAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); if (Device.CanInitiateVoiceCall) { String text = Control.Text; String phoneNumber = Control.PhoneNumber; if (String.IsNullOrEmpty(text)) { text = phoneNumber; } writer.WriteBeginTag("a"); writer.Write(" href=\"tel:"); foreach (char ch in phoneNumber) { if (ch >= '0' && ch <= '9' || ch == '#' || ch=='+') { writer.Write(ch); } } writer.Write("\""); AddAttributes(writer); writer.Write(">"); writer.WriteText(text, true); writer.WriteEndTag("a"); } else { // Format the text string based on properties String text = String.Format(CultureInfo.CurrentCulture, Control.AlternateFormat, Control.Text, Control.PhoneNumber); String url = Control.AlternateUrl; // If URI specified, create a link. Otherwise, only text is displayed. if (!String.IsNullOrEmpty(url)) { RenderBeginLink(writer, url); writer.WriteText(text, true); RenderEndLink(writer); } else { writer.WriteText(text, true); } } writer.ExitStyle(Style, Control.BreakAfter); }
/// <include file='doc\HtmlLabelAdapter.uex' path='docs/doc[@for="HtmlLabelAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { writer.EnterStyle(Style); if( (writer.BeforeFirstControlWritten) && (Device.RequiresLeadingPageBreak) && (String.IsNullOrEmpty(Control.Text) || WhiteSpace(Control.Text) ) ) { writer.WriteBreak(); } else { writer.WriteText(Control.Text, true); } writer.ExitStyle(Style, Control.BreakAfter); }
/// <include file='doc\HtmlValidationSummaryAdapter.uex' path='docs/doc[@for="HtmlValidationSummaryAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { String[] errorMessages = null; if (Control.Visible) { errorMessages = Control.GetErrorMessages(); } if (errorMessages != null) { writer.EnterStyle(Style); if (Control.HeaderText.Length > 0) { writer.WriteText(Control.HeaderText, true); } 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, StringComparison.OrdinalIgnoreCase) != 0) { _link.NavigateUrl = Constants.FormIDPrefix + Control.FormToValidate; _link.Text = String.IsNullOrEmpty(Control.BackLabel) ? GetDefaultLabel(BackLabel) : Control.BackLabel; // Summary writes its own break so last control should write one. _link.BreakAfter = false; } 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); writer.ExitStyle(Style, Control.BreakAfter); } }
/// <include file='doc\HtmlValidatorAdapter.uex' path='docs/doc[@for="HtmlValidatorAdapter.Render"]/*' /> public override void Render(HtmlMobileTextWriter writer) { if (!Control.IsValid && Control.Display != ValidatorDisplay.None) { writer.EnterStyle(Style); if (!String.IsNullOrEmpty(Control.Text)) { writer.WriteText(Control.Text, true); } else if (!String.IsNullOrEmpty(Control.ErrorMessage)) { writer.WriteText(Control.ErrorMessage, true); } writer.ExitStyle(Style, Control.BreakAfter); } }
private void RenderElement(HtmlMobileTextWriter writer, int index, int begin, int end) { TextViewElement element = Control.GetElement(index); if (end == -1) { end = element.Text.Length; } String text = element.Text; if (begin > 0 || end < text.Length) { text = text.Substring(begin, end - begin); } BooleanOption previousBold = Style.Font.Bold; BooleanOption previousItalic = Style.Font.Italic; if (element.IsBold) { Style.Font.Bold = BooleanOption.True; } if (element.IsItalic) { Style.Font.Italic = BooleanOption.True; } writer.EnterStyle(Style); if (element.Url != null) { RenderBeginLink(writer, element.Url); writer.WriteText(text, true); RenderEndLink(writer); } else { writer.WriteText(text, true); } writer.ExitStyle(Style, element.BreakAfter); Style.Font.Bold = previousBold; Style.Font.Italic = previousItalic; }
/// <include file='doc\ChtmlTextBoxAdapter.uex' path='docs/doc[@for="ChtmlTextBoxAdapter.AddAttributes"]/*' /> protected override void AddAttributes(HtmlMobileTextWriter writer) { if (Control.Numeric) { if (Device.SupportsInputIStyle) { // The default input mode is always numeric if the // type is password. if (!Control.Password) { writer.WriteAttribute("istyle", "4"); } } else if (Device.SupportsInputMode) { writer.WriteAttribute("mode", "numeric"); } } AddAccesskeyAttribute(writer); AddJPhoneMultiMediaAttributes(writer); }
/// <include file='doc\HtmlImageAdapter.uex' path='docs/doc[@for="HtmlImageAdapter.RenderImage"]/*' /> protected internal virtual void RenderImage(HtmlMobileTextWriter writer) { String source = Control.ImageUrl; writer.WriteBeginTag("img"); if (!String.IsNullOrEmpty(source)) { // AUI 3652 source = Control.ResolveUrl(source); writer.WriteAttribute("src", source, true /*encode*/); writer.AddResource(source); } if (!String.IsNullOrEmpty(Control.AlternateText)) { writer.WriteAttribute("alt", Control.AlternateText, true); } writer.WriteAttribute("border", "0"); writer.Write(" />"); }
/// <include file='doc\ChtmlFormAdapter.uex' path='docs/doc[@for="ChtmlFormAdapter.RenderPagerTag"]/*' /> protected internal override void RenderPagerTag( HtmlMobileTextWriter writer, int pageToNavigate, String text) { writer.EnterLayout(Style); writer.EnterFormat(Style); writer.WriteBeginTag("input"); // Specially encode the page number with the control id. // The corresponding code that handles postback should know how // to extract the page number correctly. writer.Write(" name=\""); writer.Write(Control.UniqueID); writer.Write(Constants.PagePrefix); writer.Write(pageToNavigate.ToString(CultureInfo.InvariantCulture)); writer.Write("\""); writer.WriteAttribute("type", "submit"); writer.WriteAttribute("value", text, true); writer.Write("/>"); writer.ExitFormat(Style); writer.ExitLayout(Style); }
public virtual void RenderPostBackEvent(HtmlMobileTextWriter writer, string target, string argument) {}
/// <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); } }
public virtual void RenderPostBackHeader(HtmlMobileTextWriter writer, System.Web.UI.MobileControls.Form form) {}
/// <include file='doc\ChtmlLinkAdapter.uex' path='docs/doc[@for="ChtmlLinkAdapter.AddAttributes"]/*' /> protected override void AddAttributes(HtmlMobileTextWriter writer) { AddAccesskeyAttribute(writer); AddJPhoneMultiMediaAttributes(writer); }
// Private overload for use with subcommands. // Style, Enter/ExitFormat included only for completeness because style // is already set for subcommands. private void RenderPostBackEventAsAnchor( HtmlMobileTextWriter writer, String argument, String linkText, Style style) { writer.EnterFormat(style); writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", argument); writer.Write(">"); writer.WriteText(linkText, true); writer.WriteEndTag("a"); writer.ExitFormat(style); }
private void RenderItemDetailsWithoutTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; writer.EnterStyle(labelStyle); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle, true); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; bool boldInStyle = (style.Font.Bold == BooleanOption.True) ? true : false; writer.EnterStyle(style); foreach (ObjectListField field in fields) { if (field.Visible) { if (!boldInStyle) { writer.Write("<b>"); } writer.WriteText(field.Title + ":", true); if (!boldInStyle) { writer.Write("</b>"); } writer.Write(" "); writer.WriteText(item[fieldIndex], true); writer.WriteBreak(); } fieldIndex++; } writer.ExitStyle(style); BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write("[ "); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterStyle(subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle); writer.Write(" | "); } String backCommandText = Control.BackCommandText.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write(" ]"); writer.ExitStyle(subCommandStyle, Control.BreakAfter); subCommandStyle.Font.Italic = cachedItalic; }
private void RenderItemsListWithTableTags(HtmlMobileTextWriter writer) { int pageStart = Control.FirstVisibleItemIndex; int pageSize = Control.VisibleItemCount; ObjectListItemCollection items = Control.Items; // Determine how to render. bool shouldRenderAsTable = ShouldRenderAsTable(); bool hasDefaultCommand = HasDefaultCommand(); bool onlyHasDefaultCommand = OnlyHasDefaultCommand(); bool requiresDetailsScreen = HasItemDetails() || (!onlyHasDefaultCommand && HasCommands()); bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand; bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand; int fieldCount; int[] fieldIndices = new int[]{}; if (shouldRenderAsTable) { fieldIndices = Control.TableFieldIndices; } Debug.Assert(fieldIndices != null, "fieldIndices is null"); fieldCount = fieldIndices.Length; if(fieldCount == 0) { fieldIndices = new int[1]; fieldIndices[0] = Control.LabelFieldIndex; fieldCount = 1; } Style style = this.Style; Style subCommandStyle = Control.CommandStyle; Style labelStyle = Control.LabelStyle; Color foreColor = (Color)style[Style.ForeColorKey, true]; writer.BeginStyleContext(); writer.WriteLine("<table border=0 width=\"100%\">\r\n<tr>"); for (int field = 0; field < fieldCount; field++) { writer.Write("<td>"); writer.BeginStyleContext(); writer.EnterStyle(labelStyle); writer.WriteText(Control.AllFields[fieldIndices[field]].Title, true); writer.ExitStyle(labelStyle); writer.EndStyleContext(); writer.Write("</td>"); } if (itemRequiresMoreButton) { writer.WriteLine("<td/>"); } writer.WriteLine("\r\n</tr>"); RenderRule(writer, foreColor, fieldCount + 1); for (int i = 0; i < pageSize; i++) { ObjectListItem item = items[pageStart + i]; writer.WriteLine("<tr>"); for (int field = 0; field < fieldCount; field++) { writer.Write("<td>"); if (field == 0 && itemRequiresHyperlink) { writer.BeginStyleContext(); writer.EnterStyle(style); String eventArgument = hasDefaultCommand ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index.ToString(CultureInfo.InvariantCulture)); RenderPostBackEventAsAnchor(writer, eventArgument, item[fieldIndices[0]]); writer.ExitStyle(style); writer.EndStyleContext(); } else { writer.BeginStyleContext(); writer.EnterStyle(style); writer.WriteText(item[fieldIndices[field]], true); writer.ExitStyle(style); writer.EndStyleContext(); } writer.WriteLine("</td>"); } if (itemRequiresMoreButton) { writer.Write("<td align=right>"); writer.BeginStyleContext(); writer.EnterFormat(subCommandStyle); String moreText = Control.MoreText.Length == 0 ? GetDefaultLabel(MoreLabel) : Control.MoreText; RenderPostBackEventAsAnchor(writer, String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), moreText, subCommandStyle); writer.ExitFormat(subCommandStyle); writer.EndStyleContext(); writer.Write("</td>\r\n"); } writer.WriteLine("</tr>"); } RenderRule(writer, foreColor, fieldCount + 1); writer.Write("</table>\r\n"); writer.EndStyleContext(); }
private void RenderItemsListWithoutTableTags(HtmlMobileTextWriter 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; writer.EnterStyle(labelStyle); writer.WriteText(Control.AllFields[labelFieldIndex].Title, true); writer.ExitStyle(labelStyle, true); 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; writer.EnterStyle(style); for (int i = startIndex; i < nextStartIndex; i++) { ObjectListItem item = items[i]; if (itemRequiresHyperlink) { RenderPostBackEventAsAnchor(writer, hasDefaultCommand ? item.Index.ToString(CultureInfo.InvariantCulture) : String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index), item[labelFieldIndex]); } else { writer.WriteText(item[labelFieldIndex], true); } if (itemRequiresMoreButton) { BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterFormat(subCommandStyle); writer.Write(" ["); writer.ExitFormat(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterFormat(subCommandStyle); String moreText = Control.MoreText.Length == 0 ? GetDefaultLabel(MoreLabel) : Control.MoreText; writer.WriteBeginTag("a"); RenderPostBackEventAsAttribute(writer, "href", String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index)); writer.Write(">"); writer.WriteText(moreText, true); writer.WriteEndTag("a"); writer.ExitFormat(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterFormat(subCommandStyle); writer.Write("]"); writer.ExitFormat(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; } if(i < (nextStartIndex - 1)) { writer.WriteBreak(); } } writer.ExitStyle(style, Control.BreakAfter); }
/// <include file='doc\HtmlObjectListAdapter.uex' path='docs/doc[@for="HtmlObjectListAdapter.RenderItemDetails"]/*' /> protected virtual void RenderItemDetails(HtmlMobileTextWriter writer, ObjectListItem item) { if (Control.AllFields.Count == 0) { return; } if(Device.Tables) { RenderItemDetailsWithTableTags(writer, item); } else { RenderItemDetailsWithoutTableTags(writer, item); } }
private void RenderItemDetailsWithTableTags(HtmlMobileTextWriter writer, ObjectListItem item) { Style style = this.Style; Style labelStyle = Control.LabelStyle; Style subCommandStyle = Control.CommandStyle; Color foreColor = (Color)style[Style.ForeColorKey, true]; writer.Write("<table border=0 width=\"100%\">\r\n<tr><td colspan=2>"); writer.BeginStyleContext(); writer.EnterStyle(labelStyle); writer.WriteText(item[Control.LabelFieldIndex], true); writer.ExitStyle(labelStyle); writer.EndStyleContext(); writer.Write("</td></tr>\r\n<tr>"); RenderRule(writer, foreColor, 2); IObjectListFieldCollection fields = Control.AllFields; int fieldIndex = 0; foreach (ObjectListField field in fields) { if (field.Visible) { writer.Write("<tr><td>"); writer.BeginStyleContext(); writer.EnterStyle(Style); writer.WriteText(field.Title, true); writer.ExitStyle(Style); writer.EndStyleContext(); writer.Write("</td><td>"); writer.BeginStyleContext(); writer.EnterStyle(style); writer.WriteText(item[fieldIndex], true); writer.ExitStyle(style); writer.EndStyleContext(); writer.Write("</td></tr>\r\n"); } fieldIndex++; } RenderRule(writer, foreColor, 2); writer.Write("<tr><td colspan=2>"); writer.BeginStyleContext(); BooleanOption cachedItalic = subCommandStyle.Font.Italic; subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write("[ "); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EnterStyle(subCommandStyle); ObjectListCommandCollection commands = Control.Commands; foreach (ObjectListCommand command in commands) { RenderPostBackEventAsAnchor(writer, command.Name, command.Text, subCommandStyle); writer.Write(" | "); } String backCommandText = Control.BackCommandText.Length == 0 ? GetDefaultLabel(BackLabel) : Control.BackCommandText; RenderPostBackEventAsAnchor(writer, BackToList, backCommandText, subCommandStyle); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = BooleanOption.False; writer.EnterStyle(subCommandStyle); writer.Write(" ]"); writer.ExitStyle(subCommandStyle); subCommandStyle.Font.Italic = cachedItalic; writer.EndStyleContext(); writer.Write("</td></tr></table>"); }
/// <include file='doc\ChtmlFormAdapter.uex' path='docs/doc[@for="ChtmlFormAdapter.RenderExtraHeadElements"]/*' /> protected override bool RenderExtraHeadElements(HtmlMobileTextWriter writer) { bool result = false; String metaTagName = Device.RequiredMetaTagNameValue; if (metaTagName != null) { if (writer != null) { writer.Write("<meta NAME=\"" + metaTagName + "\" CONTENT=\"True\">\r\n"); } result = true; } String charset = Page.Response.Charset; if (Device.RequiresContentTypeMetaTag && charset != null && charset.Length > 0) { if (writer != null) { writer.Write(String.Format(CultureInfo.InvariantCulture, _contentTypeMetaTag, Device.PreferredRenderingMime, charset)); } result = true; } return result; }
/// <include file='doc\HtmlObjectListAdapter.uex' path='docs/doc[@for="HtmlObjectListAdapter.RenderItemsList"]/*' /> protected virtual void RenderItemsList(HtmlMobileTextWriter writer) { Debug.Assert (Control.VisibleItemCount <= Control.Items.Count); if (Control.VisibleItemCount == 0) { return; } Debug.Assert (Control.AllFields != null && Control.AllFields.Count > 0, "Should never have items but no fields."); if (Device.Tables) { RenderItemsListWithTableTags(writer); } else { RenderItemsListWithoutTableTags(writer); } }
// Methods public virtual void Render(HtmlMobileTextWriter writer) {}
private void RenderRule(HtmlMobileTextWriter writer, Color foreColor, int columnSpan) { writer.Write("<tr><td colspan="); writer.Write(columnSpan.ToString(CultureInfo.InvariantCulture)); writer.Write(" bgcolor=\""); writer.Write((foreColor != Color.Empty) ? ColorTranslator.ToHtml(foreColor) : "#000000"); writer.Write("\"></td></tr>"); }