protected override void OnClick(EventArgs e) { base.OnClick(e); if (CausesValidation && !Page.IsValid) { return; } // Redirect to the form submission URL with all the form values, except for empty ones. var parameters = new string[_fields.Count * 2]; for (int i = 0, j = 0; i < _fields.Count; i++, j += 2) { FormField field = _fields[i]; parameters[j] = field.Name; parameters[j + 1] = field.Input != null ? GetControlValue(field.Input, field.ExtraData).NullIfEmpty() : field.ExtraData.ToString(); } var url = new ReadOnlyApplicationUrl(GetFormUrl(), new QueryString(parameters)); Page.Response.Redirect(url.ToString()); }
public string MapBody(Guid jobAdId, IList <string> bulletPoints, string contentHtml) { // Job ad link. var applyLink = new TagBuilder("a") { InnerHtml = "Please click here to apply." }; var applyUrl = new ReadOnlyApplicationUrl("~/jobs/" + jobAdId.ToString()); applyLink.MergeAttribute("href", applyUrl.ToString()); var applyLinkBold = new TagBuilder("b") { InnerHtml = applyLink.ToString() }; var applyHtmlBottom = "<br/><br/>" + applyLinkBold; // Map bullet points. var bulletPointsHtml = string.Empty; if (bulletPoints != null && bulletPoints.Count != 0) { var listItems = bulletPoints.Aggregate(new StringBuilder(), (agg, bulletPoint) => { // Make sure that is looks good on Search Results page var lastChar = bulletPoint[bulletPoint.Length - 1]; if (lastChar != '.' && lastChar != ',' && lastChar != ';' && lastChar != '!') { bulletPoint += ". "; } else { bulletPoint += " "; } var listItem = new TagBuilder("li"); listItem.SetInnerText(bulletPoint); return(agg.Append(listItem.ToString())); }); var list = new TagBuilder("ul") { InnerHtml = listItems.ToString() }; bulletPointsHtml = list.ToString(); } // Map content. var contentText = HtmlUtil.StripHtmlTags(contentHtml, "p", "li"); // Remove any attributes. contentText = RemoveAttributes(contentText); // Process some things manually. contentText = contentText.Replace("<p>", ""); contentText = contentText.Replace("</p>", "\n\n"); contentText = contentText.Replace("<li>", ""); contentText = contentText.Replace("</li>", "\n\n"); if (contentText.EndsWith("\n\n")) { contentText = contentText.Substring(0, contentText.Length - 2); } contentText = contentText.Replace('\u0095', '\u2022'); // replace Windows Western bullet with Unicode bullet contentText = contentText.Replace(" ", new string('\u00A0', 1)); contentText = contentText.Replace("&", "&"); contentText = contentText.Replace(""", "\""); var contentSimpleHtml = BuildContentSimpleHtml(contentText, _maxDescriptionLength - (bulletPointsHtml.Length + applyHtmlBottom.Length)); return(bulletPointsHtml + contentSimpleHtml + applyHtmlBottom); }
public static string MungeUrl(this HtmlHelper htmlHelper, ReadOnlyApplicationUrl url) { return(url.ToString().Replace("/", "~@~")); }