public DocumentZone(HtmlHelper html, string targetZone, ZoneInjectMode injectMode, string key) { Guard.NotEmpty(targetZone, nameof(targetZone)); _viewContext = html.ViewContext; _originalViewContextWriter = _viewContext.Writer; _page = (WebViewPage)html.ViewDataContainer; var writer = new StringWriter(); _page.OutputStack.Push(writer); _viewContext.Writer = writer; _targetZone = targetZone; _injectMode = injectMode; if (key.HasValue()) { if (HasUniqueKey(key)) { _isVoid = true; } else { UniqueKeys.Add(key); } } if (_page.Request.IsAjaxRequest()) { _isVoid = true; } }
public static IDisposable BeginZoneContent(this HtmlHelper helper, string targetZone, ZoneInjectMode injectMode = ZoneInjectMode.Append, string key = null) { return(new DocumentZone(helper, targetZone, injectMode, key)); }
public static IDisposable BeginZoneContent(this HtmlHelper helper, string targetZone, ZoneInjectMode injectMode = ZoneInjectMode.Append, string key = null) { if (key.HasValue() && DocumentZone.HasUniqueKey(key)) { return(ActionDisposable.Empty); } return(new DocumentZone((WebViewPage)helper.ViewDataContainer, targetZone, injectMode, key)); }
public DocumentZone(WebViewPage page, string targetZone, ZoneInjectMode injectMode, string key) { Guard.NotEmpty(targetZone, nameof(targetZone)); _page = page; _page.OutputStack.Push(new StringWriter()); _targetZone = targetZone; _injectMode = injectMode; if (key.HasValue()) { UniqueKeys.Add(key); } }