protected override void Render(HtmlTextWriter writer)
        {
            var errorMessages = GetErrorMessages().ToArray();

            writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);

            if (!errorMessages.Any()) {
                writer.AddAttribute(HtmlTextWriterAttribute.Style, "display: none;");
            }

            using (writer.RenderTag(HtmlTextWriterTag.Div)) {
                if (!String.IsNullOrEmpty(HeaderText)) {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "header");
                    using (writer.RenderTag(HtmlTextWriterTag.Span)) {
                        writer.WriteEncodedText(HeaderText);
                    }
                }

                if (errorMessages.Any()) {
                    using (writer.RenderTag(HtmlTextWriterTag.Ul)) {
                        foreach (var message in errorMessages) {
                            if (message == null)
                                continue;

                            using (writer.RenderTag(HtmlTextWriterTag.Li)) {
                                writer.Write(message);
                            }
                        }
                    }
                }
            }
        }
		/// <summary>
		/// Renders the output of the control
		/// </summary>
		/// <param name="output">The response writer.</param>
		protected override void DoRender(HtmlTextWriter output)
		{
			using (output.RenderTag(
				HtmlTextWriterTag.Script,
				new HtmlAttribute(HtmlTextWriterAttribute.Type, "text/javascript"),
				new HtmlAttribute(HtmlTextWriterAttribute.Src, this.GetAbsoluteUrl(this.Src))))
			{
				// nothing needed inside.
			}
		}
Exemplo n.º 3
0
        /// <summary>
        /// Renders the contents of the control to the specified writer. This method is used primarily by control developers.
        /// </summary>
        /// <param name="writer">A <see cref="T:System.Web.UI.HtmlTextWriter"/> that represents the output stream to render HTML content on the client.</param>
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (this.EventArgs != null) {

                writer.RenderTag(HtmlTextWriterTag.Legend, "Server side rendered content");

                // start address/location
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#EEE");
                using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                    writer.RenderTag(HtmlTextWriterTag.B, "Start address: ");
                    writer.Write(this.EventArgs.StartAddress);
                    writer.RenderTag(HtmlTextWriterTag.B, " / Start location: ");
                    writer.Write(this.EventArgs.StartLocation.ToString());
                }

                // steps
                foreach (var step in this.EventArgs.Steps) {
                    writer.AddStyleAttribute("border-bottom", "solid 1px #CCC");
                    using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                        writer.Write(step.Instructions);
                        writer.Write(" | ");
                        writer.RenderTag(HtmlTextWriterTag.B, "Distance: ");
                        writer.Write(step.Distance.Text);
                        writer.Write(" | ");
                        writer.RenderTag(HtmlTextWriterTag.B, "Duration: ");
                        writer.Write(step.Duration.Text);
                    }
                }

                // end address/location
                writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#EEE");
                using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                    writer.RenderTag(HtmlTextWriterTag.B, "End address: ");
                    writer.Write(this.EventArgs.EndAddress);
                    writer.RenderTag(HtmlTextWriterTag.B, " / End location: ");
                    writer.Write(this.EventArgs.EndLocation.ToString());
                }

                // distance
                using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                    writer.RenderTag(HtmlTextWriterTag.B, "Total Distance: ");
                    writer.Write(this.EventArgs.Distance.Text);
                }
                // durarion
                using (writer.BeginTag(HtmlTextWriterTag.Div)) {
                    writer.RenderTag(HtmlTextWriterTag.B, "Total Duration: ");
                    writer.Write(this.EventArgs.Duration.Text);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// The render service options.
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="controlId">
        /// The control id.
        /// </param>
        protected void RenderServiceOptions(HtmlTextWriter output, string source, string controlId)
        {
            // TODO: Ed, this appears to be very CW centric, can we make it more generalized in name?
            var current = Client.GetItemNotNull(this.ItemID, global::Sitecore.Context.ContentDatabase);
            var siteItem = current.Axes.SelectSingleItem("ancestor-or-self::*[contains(@@templatename, 'Site')]");

            var luceneQuery = source.Replace("lucene:", string.Empty);

            var qh = new QueryStringHelper(luceneQuery);

            var templateid = qh.GetByName("templateid");
            var fullSiteSearch = false;

            if (qh.NameExists("fullsite"))
            {
                fullSiteSearch = qh.GetByName<bool>("fullsite");
            }

            using (output.RenderTag(HtmlTextWriterTag.Script, new HtmlAttribute("type", "text/javascript")))
            {
                output.WriteLine("jQuery(\"#{0}\").tokenInput(\"/tokenizedlisthandler.axd\", ".FormatWith(controlId));

                output.WriteLine("{theme: \"facebook\", ");
                output.WriteLine("tokenDelimiter: \"|\", ");
                output.WriteLine("preventDuplicates: true, ");
                output.WriteLine("makeSortable: true, ");
                output.WriteLine("minChars: 3,");
                output.WriteLine("luceneFullSite: \"{0}\",".FormatWith(fullSiteSearch));
                output.WriteLine("luceneLanguage: \"{0}\",".FormatWith(this.ItemLanguage));
                if (siteItem != null && !fullSiteSearch)
                {
                    output.WriteLine("luceneSiteName: \"{0}\",".FormatWith(siteItem.Key));
                }

                if (!string.IsNullOrEmpty(templateid))
                {
                    output.WriteLine("luceneTemplateId: \"{0}\",".FormatWith(templateid));
                }

                output.WriteLine("parseName: function(item) { ");
                output.WriteLine("    if (typeof item.site !== \"undefined\") { ");
                output.WriteLine("		if (item.site == null) { ");
                output.WriteLine("			return \"Unmatched People >\" + item.name; ");
                output.WriteLine("		} else {");
                output.WriteLine("      return item.site + \" >\" + item.name; ");
                output.WriteLine("		} ");
                output.WriteLine("	  } ");
                output.WriteLine("	  return item.name; ");
                output.WriteLine("}, ");
                output.WriteLine("disabled: " + this.Disabled.ToString().ToLowerInvariant());

                if (fullSiteSearch)
                {
                    this.RenderValueWithSite(output);
                }
                else
                {
                    this.RenderValue(output);
                }

                output.WriteLine("});");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// The render manual options.
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="controlId">
        /// The control id.
        /// </param>
        protected void RenderManualOptions(HtmlTextWriter output, string source, string controlId)
        {
            // TODO: Ed, this appears to be very CW centric, can we make it more generalized in name?
            var current = Client.GetItemNotNull(this.ItemID, global::Sitecore.Context.ContentDatabase);

            var items = this.GetItems(current, this.Source);

            using (output.RenderTag(HtmlTextWriterTag.Script, new HtmlAttribute("type", "text/javascript")))
            {
                output.WriteLine("jQuery(\"#{0}\").tokenInput([".FormatWith(controlId));
                foreach (var item in items)
                {
                    var langItem = item.GetBestFitLanguageVersion(Language.Parse(this.ItemLanguage));
                    output.WriteLine("{{id: \"{0}\", name: {1}}},".FormatWith(langItem.ID, StringUtil.EscapeJavascriptString(langItem.DisplayName)));
                }

                output.WriteLine("],");
                output.WriteLine("{theme: \"facebook\", ");
                output.WriteLine("tokenDelimiter: \"|\", ");
                output.WriteLine("preventDuplicates: true, ");
                output.WriteLine("makeSortable: true, ");
                output.WriteLine("disabled: " + this.Disabled.ToString().ToLowerInvariant());

                this.RenderValue(output);

                output.WriteLine("});");
            }
        }