/// <summary> /// Renders the resource in the specified <see cref="IHtmlWriter" />. /// </summary> public override void Render(IHtmlWriter writer, IDotvvmRequestContext context) { if (CdnUrl != null) { writer.AddAttribute("src", CdnUrl); writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.RenderEndTag(); if (Url != null && GlobalObjectName != null) { writer.RenderBeginTag("script"); var url = context.TranslateVirtualPath(GetUrl()); writer.WriteUnencodedText(string.Format(CdnFallbackScript, GlobalObjectName, url)); writer.RenderEndTag(); } } else if (Url != null) { writer.AddAttribute("src", GetUrl()); writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.RenderEndTag(); } }
protected override void RenderControl(IHtmlWriter writer) { // begin if (Mode == TextMode.MultiLine) { writer.RenderBeginTag("textarea"); } else { writer.RenderBeginTag("input"); writer.AddAttribute("type", Mode.ToString().ToLower()); } // content var expr = KnockoutBindingHelper.GetBindingExpressionOrNull(TextProperty, this); if (!KnockoutBindingHelper.IsKnockoutBinding(expr)) { if (Mode == TextMode.MultiLine) { writer.WriteText(Text, true); } else { writer.AddAttribute("value", Text); } } else { writer.AddBindingAttribute("value", KnockoutBindingHelper.TranslateToKnockoutProperty(this, TextProperty, expr)); } // end writer.RenderEndTag(); }
/// <summary> /// Renders the specified writer. /// </summary> protected override void RenderControl(IHtmlWriter writer) { writer.RenderBeginTag("table"); if (ItemTemplate != null) { var itemsSourceExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(ItemsSourceProperty, this); if (KnockoutBindingHelper.IsKnockoutBinding(itemsSourceExpression)) { // knockout template writer.RenderBeginTag("tbody"); writer.AddBindingAttribute("foreach", KnockoutBindingHelper.TranslateToKnockoutProperty(this, ItemsSourceProperty, itemsSourceExpression)); if (string.IsNullOrEmpty(KeyPropertyName)) { ItemTemplate.DataContext = CreateClientTemplateInstanceDataContextBinding(); } else { ItemTemplate.DataContext = CreateClientTemplateInstanceDataContextBinding(KeyPropertyName); } ItemTemplate.Render(writer); writer.RenderEndTag(); } else if (ItemsSource != null) { writer.RenderBeginTag("tbody"); var index = 0; var rawItemsSourceValue = this.GetRawValue(ItemsSourceProperty); foreach (var item in ItemsSource) { // render on server side writer.RenderBeginTag("tr"); if (string.IsNullOrEmpty(KeyPropertyName) || item == null) { ItemTemplate.DataContext = CreateServerTemplateInstanceDataContextBinding(index); } else { var keyValue = GetKeyValue(item); ItemTemplate.DataContext = CreateServerTemplateInstanceDataContextBinding(KeyPropertyName, keyValue); } ItemTemplate.Render(writer); writer.RenderEndTag(); index++; } writer.RenderEndTag(); } } writer.RenderEndTag(); }
private static void RenderProgressWrapper(IHtmlWriter writer) { // render progress wrapper writer.AddKnockoutDataBind("visible", "IsBusy"); writer.AddAttribute("class", "dotvvm-upload-progress-wrapper"); writer.RenderBeginTag("span"); writer.AddAttribute("class", "dotvvm-upload-progress"); writer.AddKnockoutDataBind("style", "{ 'width': (Progress() == -1 ? '50' : Progress()) + '%' }"); writer.RenderBeginTag("span"); writer.RenderEndTag(); writer.RenderEndTag(); }
private void RenderUploadButton(IHtmlWriter writer) { // render upload button writer.AddAttribute("class", "dotvvm-upload-button"); writer.AddKnockoutDataBind("visible", "!IsBusy()"); writer.RenderBeginTag("span"); writer.AddAttribute("href", "#"); writer.AddAttribute("onclick", "dotvvm.fileUpload.showUploadDialog(this); return false;"); writer.RenderBeginTag("a"); writer.WriteText(UploadButtonText); writer.RenderEndTag(); writer.RenderEndTag(); }
protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context) { // render resource links var resourceManager = context.ResourceManager; if (resourceManager.BodyRendered) return; resourceManager.BodyRendered = true; // set the flag before the resources are rendered, so they can't add more resources to the list during the render foreach (var resource in resourceManager.GetNamedResourcesInOrder()) { if (resource.Resource.RenderPosition == ResourceRenderPosition.Body) resource.RenderResourceCached(writer, context); } // render the serialized viewmodel var serializedViewModel = ((DotvvmRequestContext) context).GetSerializedViewModel(); writer.AddAttribute("type", "hidden"); writer.AddAttribute("id", "__dot_viewmodel_root"); writer.AddAttribute("value", serializedViewModel); writer.RenderSelfClosingTag("input"); // init on load writer.RenderBeginTag("script"); writer.WriteUnencodedText($@" window.dotvvm.domUtils.onDocumentReady(function () {{ window.dotvvm.init('root', {JsonConvert.ToString(CultureInfo.CurrentCulture.Name, '"', StringEscapeHandling.EscapeHtml)}); }});"); writer.RenderEndTag(); }
/// <summary> /// Renders the contents inside the control begin and end tags. /// </summary> protected override void RenderContents(IHtmlWriter writer, RenderContext context) { if (RenderOnServer) { // render items bool first = true; foreach (var item in GetIEnumerableFromDataSource(DataSource)) { var value = string.IsNullOrEmpty(ValueMember) ? item : ReflectionUtils.GetObjectProperty(item, ValueMember); var text = string.IsNullOrEmpty(DisplayMember) ? item : ReflectionUtils.GetObjectProperty(item, DisplayMember); if (first) { writer.WriteUnencodedText(Environment.NewLine); first = false; } writer.WriteUnencodedText(" "); //Indent writer.AddAttribute("value", value != null ? value.ToString() : ""); writer.RenderBeginTag("option"); writer.WriteText(text != null ? text.ToString() : ""); writer.RenderEndTag(); writer.WriteUnencodedText(Environment.NewLine); } } }
/// <summary> /// Renders the contents inside the control begin and end tags. /// </summary> protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context) { // render template writer.AddKnockoutDataBind("text", "errorMessage"); writer.RenderBeginTag("li"); writer.RenderEndTag(); }
protected override void RenderEndTag(IHtmlWriter writer, IDotvvmRequestContext context) { if (RenderWrapperTag) { base.RenderEndTag(writer, context); } if (!RenderOnServer && !RenderWrapperTag) { writer.WriteKnockoutDataBindEndComment(); } if (!RenderOnServer && SeparatorTemplate != null) { writer.AddAttribute("type", "text/html"); writer.AddAttribute("id", GetValueRaw(Internal.UniqueIDProperty) + "_separator"); var unique = GetValueRaw(Internal.UniqueIDProperty); var id = GetValueRaw(Internal.ClientIDFragmentProperty); writer.RenderBeginTag("script"); GetSeparator(context).Render(writer, context); writer.RenderEndTag(); } emptyDataContainer?.Render(writer, context); }
/// <summary> /// Renders the control into the specified writer. /// </summary> protected override void RenderControl(IHtmlWriter writer, RenderContext context) { // render resource links var resources = context.ResourceManager.GetResourcesInOrder().Where(r => r.GetRenderPosition() == ResourceRenderPosition.Body); foreach (var resource in resources) { resource.Render(writer); } // render the serialized viewmodel var serializedViewModel = context.RequestContext.GetSerializedViewModel(); writer.AddAttribute("type", "hidden"); writer.AddAttribute("id", "__dot_viewmodel_" + context.CurrentPageArea); writer.AddAttribute("value", serializedViewModel); writer.RenderSelfClosingTag("input"); // init on load writer.RenderBeginTag("script"); writer.WriteUnencodedText($@" window.dotvvm.domUtils.onDocumentReady(function () {{ window.dotvvm.init('{context.CurrentPageArea}', '{Thread.CurrentThread.CurrentUICulture.Name}'); }});"); writer.RenderEndTag(); }
/// <summary> /// Renders the control begin tag. /// </summary> protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context) { if (RendersHtmlTag) { writer.RenderBeginTag(TagName); } }
protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context) { if (isLabelRequired) { writer.RenderBeginTag("label"); } }
public override void RenderLink(IResourceLocation location, IHtmlWriter writer, IDotvvmRequestContext context, string resourceName) { AddSrcAndIntegrity(writer, context, location.GetUrl(context, resourceName), "src"); writer.AddAttribute("type", MimeType); writer.RenderBeginTag("script"); writer.RenderEndTag(); }
/// <summary> /// Renders the resource in the specified <see cref="IHtmlWriter" />. /// </summary> public override void Render(IHtmlWriter writer, string friendlyName = null) { writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.WriteUnencodedText(Code); writer.RenderEndTag(); }
public override void Render(IHtmlWriter writer, IDotvvmRequestContext context, string resourceName) { writer.AddAttribute("amp-boilerplate", null); writer.RenderBeginTag("style"); writer.WriteUnencodedText(BoilerPlateCode); writer.RenderEndTag(); writer.RenderBeginTag("noscript"); writer.AddAttribute("amp-boilerplate", null); writer.RenderBeginTag("style"); writer.WriteUnencodedText(BoilerPlateCodeNoScript); writer.RenderEndTag(); writer.RenderEndTag(); }
private void RenderUploadedFilesTitle(IHtmlWriter writer) { // render upload files writer.AddAttribute("class", "dotvvm-upload-files"); writer.AddKnockoutDataBind("html", $"dotvvm.globalize.format({KnockoutHelper.MakeStringLiteral(NumberOfFilesIndicatorText!)}, Files().length)"); writer.RenderBeginTag("span"); writer.RenderEndTag(); }
private void RenderIframe(IHtmlWriter writer) { // render iframe writer.AddAttribute("class", "dotvvm-upload-iframe"); writer.AddAttribute("src", GetFileUploadHandlerUrl()); writer.RenderBeginTag("iframe"); writer.RenderEndTag(); }
protected override void RenderControl(IHtmlWriter writer) { writer.RenderBeginTag(Element); if (htmlAttributesStorage != null) htmlAttributesStorage.Render(writer); base.RenderControl(writer); writer.RenderEndTag(true); }
private void RenderIframe(IHtmlWriter writer) { // render iframe writer.AddAttribute("class", "dotvvm-upload-iframe"); writer.AddAttribute("src", "~/" + HostingConstants.FileUploadHandlerMatchUrl + (AllowMultipleFiles ? "?multiple=true" : "")); writer.RenderBeginTag("iframe"); writer.RenderEndTag(); }
private void RenderLabel(IHtmlWriter writer) { writer.AddAttribute("class", "control-label col-sm-2"); var textBinding = GetBinding(LabelTextProperty); if (textBinding != null) { writer.AddKnockoutDataBind("text", this, LabelTextProperty, () => { }); writer.RenderBeginTag("label"); writer.RenderEndTag(); } else { writer.RenderBeginTag("label"); writer.WriteText(LabelText); writer.RenderEndTag(); } }
/// <summary> /// Renders the resource in the specified <see cref="IHtmlWriter" />. /// </summary> public override void Render(IHtmlWriter writer, IDotvvmRequestContext context) { if (string.IsNullOrWhiteSpace(Code)) return; writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.WriteUnencodedText(Code); writer.RenderEndTag(); }
private void RenderUploadedFilesTitle(IHtmlWriter writer) { // render upload files writer.AddAttribute("class", "dotvvm-upload-files"); writer.AddKnockoutDataBind("html", $"dotvvm.globalize.format({JsonConvert.SerializeObject(NumberOfFilesIndicatorText)}, Files().length)"); writer.RenderBeginTag("span"); writer.RenderEndTag(); }
public void RenderPreloadLink(IHtmlWriter writer, IDotvvmRequestContext context, string resourceName) { writer.AddAttribute("rel", "preload"); writer.AddAttribute("href", Location.GetUrl(context, resourceName)); writer.AddAttribute("as", "script"); writer.RenderBeginTag("link"); writer.RenderEndTag(); }
private static void RenderNotPicked(IHtmlWriter writer) { writer.AddStyleAttribute("margin-left", "-23px"); writer.AddStyleAttribute("margin-bottom", "100px"); writer.AddStyleAttribute("width", "13px"); writer.AddStyleAttribute("background-color", "#C44"); writer.AddStyleAttribute("display", "inline-block"); writer.RenderBeginTag("span"); writer.RenderEndTag(); }
private void RenderCheckboxPicture(IHtmlWriter writer) { writer.AddKnockoutDataBind("attr", BuildKnockoutBidningLabelAttributes()); writer.AddKnockoutDataBind("text", this, NameProperty, () => { writer.AddAttribute("text", Name); }); writer.RenderBeginTag("label"); writer.RenderEndTag(); }
protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context) { if (HasValueBinding(EnabledProperty)) { writer.WriteKnockoutDataBindComment("dotvvm_introduceAlias", $"{{ '$pagerEnabled': { GetValueBinding(EnabledProperty).GetKnockoutBindingExpression() }}}"); } writer.AddKnockoutDataBind("with", this, DataSetProperty, renderEvenInServerRenderingMode: true); writer.RenderBeginTag("ul"); }
protected override void RenderBeginTag(IHtmlWriter writer, RenderContext context) { if (HideWhenOnlyOnePage) { writer.AddKnockoutDataBind("visible", "ko.unwrap(" + GetDataSetBinding().GetKnockoutBindingExpression() + ").PagesCount() > 1"); } writer.AddKnockoutDataBind("with", this, DataSetProperty, renderEvenInServerRenderingMode: true); writer.RenderBeginTag("ul"); }
protected override void RenderContents(IHtmlWriter writer, RenderContext context) { RenderLabel(writer); writer.AddAttribute("class", "col-sm-10"); writer.RenderBeginTag("div"); RenderChildren(writer, context); writer.RenderEndTag(); }
/// <summary> /// Renders the resource in the specified <see cref="IHtmlWriter" />. /// </summary> public override void Render(IHtmlWriter writer, IDotvvmRequestContext context) { if (string.IsNullOrWhiteSpace(Code)) { return; } writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.WriteUnencodedText(Code); writer.RenderEndTag(); }
protected override void RenderControl(IHtmlWriter writer) { var textExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(TextProperty, this); var needsLabel = KnockoutBindingHelper.IsKnockoutBinding(textExpression) || !string.IsNullOrEmpty(Text); // render the checkbox writer.RenderBeginTag("input"); writer.AddAttribute("type", "radio"); var valueExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(ValueProperty, this); if (KnockoutBindingHelper.IsKnockoutBinding(valueExpression)) { writer.AddBindingAttribute("value", KnockoutBindingHelper.TranslateToKnockoutProperty(this, ValueProperty, valueExpression)); } else { writer.AddAttribute("value", Value); } writer.AddAttribute("name", GroupName); var selectedValueExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(SelectedValueProperty, this); if (KnockoutBindingHelper.IsKnockoutBinding(selectedValueExpression)) { writer.AddBindingAttribute("checked", KnockoutBindingHelper.TranslateToKnockoutProperty(this, SelectedValueProperty, selectedValueExpression)); } else { writer.AddAttribute("checked", IsChecked ? "checked" : ""); } if (needsLabel) { EnsureHasID(); writer.AddAttribute("id", ID); } writer.RenderEndTag(); // render the label if (needsLabel) { writer.RenderBeginTag("label"); writer.AddAttribute("for", ID); if (KnockoutBindingHelper.IsKnockoutBinding(textExpression)) { writer.AddBindingAttribute("", KnockoutBindingHelper.TranslateToKnockoutProperty(this, TextProperty, textExpression)); } else { writer.WriteText(Text, true); } writer.RenderEndTag(); } }
protected override void RenderControl(IHtmlWriter writer) { if (InternalScriptUrls != null) { foreach (var script in InternalScriptUrls) { writer.RenderBeginTag("script"); writer.AddAttribute("type", "text/javascript"); writer.AddAttribute("src", script); writer.RenderEndTag(true); } } writer.RenderBeginTag("script"); writer.AddAttribute("type", "text/javascript"); writer.WriteText("(function () { var viewModelData = ", false); writer.WriteText(SerializedViewModel, false); writer.WriteText(";var vm = Redwood.CreateViewModel(viewModelData, new " + ViewModelClientName + "());ko.applyBindings(vm);Redwood.ViewModels['Default'] = vm;})();", false); writer.RenderEndTag(); }
private void RenderResultTitle(IHtmlWriter writer) { // render result writer.AddAttribute("class", "dotvvm-upload-result"); writer.AddKnockoutDataBind("html", $"Error() ? {JsonConvert.SerializeObject(UploadErrorMessageText)} : {JsonConvert.SerializeObject(SuccessMessageText)}"); writer.AddKnockoutDataBind("attr", "{ title: Error }"); writer.AddKnockoutDataBind("css", "{ 'dotvvm-upload-result-success': !Error(), 'dotvvm-upload-result-error': Error }"); writer.AddKnockoutDataBind("visible", "!IsBusy() && Files().length > 0"); writer.RenderBeginTag("span"); writer.RenderEndTag(); }
private void RenderPicked(IHtmlWriter writer) { writer.AddKnockoutDataBind("visible", GetValueBinding(CheckedProperty)); writer.AddStyleAttribute("margin-left", "-13px"); writer.AddStyleAttribute("margin-bottom", "100px"); writer.AddStyleAttribute("width", "13px"); writer.AddStyleAttribute("background-color", "#2E2"); writer.AddStyleAttribute("color", "#2E2"); writer.AddStyleAttribute("display", "inline-block"); writer.RenderBeginTag("span"); writer.RenderEndTag(); }
/// <summary> /// Renders the control begin tag. /// </summary> protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context) { if (HasBinding(IncludeInPageProperty)) { writer.WriteKnockoutDataBindComment("if", this, IncludeInPageProperty); } if (RendersHtmlTag) { writer.RenderBeginTag(TagName); } }
public override void Render(IHtmlWriter writer, IDotvvmRequestContext context, string resourceName) { var resource = (ScriptResource)context.ResourceManager.FindResource(ResourceConstants.PolyfillBundleResourceName); var resourceUrl = context.TranslateVirtualPath( resource.Location.GetUrl(context, ResourceConstants.PolyfillBundleResourceName)); writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.WriteUnencodedText($"dotvvm__polyfillUrl = '{resourceUrl}';"); writer.RenderEndTag(); }
public override void Render(IHtmlWriter writer, IDotvvmRequestContext context, string resourceName) { var code = resources.GetAmpKeyframesCode(context).Result; if (!string.IsNullOrWhiteSpace(code)) { writer.AddAttribute("amp-keyframes", null); writer.RenderBeginTag("style"); writer.WriteUnencodedText(code); writer.RenderEndTag(); } }
public virtual void RenderBeginTag(string name) { if (validator.CheckHtmlTag(name, Attributes)) { Attributes.Clear(); writer.RenderBeginTag(name); } else { Logger?.LogError($"Html tag {name} not rendered. All its content will not be rendered."); StartTagSkipped = true; } }
/// <summary> /// Renders the control to the writer. /// </summary> protected override void RenderControl(IHtmlWriter writer) { writer.RenderBeginTag("select"); var itemsSourceExpression = KnockoutBindingHelper.GetBindingExpressionOrNull(ItemsSourceProperty, this); if (KnockoutBindingHelper.IsKnockoutBinding(itemsSourceExpression)) { // render items on client writer.AddBindingAttribute("options", KnockoutBindingHelper.TranslateToKnockoutProperty(this, ItemsSourceProperty, itemsSourceExpression)); if (DisplayNullItem) { writer.AddBindingAttribute("optionsCaption", NullItemText); } if (DisplayMemberBinding != null) { writer.AddBindingAttribute("optionsText", KnockoutBindingHelper.TranslateToKnockoutProperty(this, DisplayMemberBindingProperty, DisplayMemberBinding)); } if (ValueMemberBinding != null) { writer.AddBindingAttribute("optionsValue", KnockoutBindingHelper.TranslateToKnockoutProperty(this, ValueMemberBindingProperty, ValueMemberBinding)); } } else if (ItemsSource != null) { // render items on server if (DisplayNullItem) { writer.RenderBeginTag("option"); writer.AddAttribute("value", ""); writer.WriteText(NullItemText, true); writer.RenderEndTag(); } // render on server foreach (var item in ItemsSource) { var itemValue = EvaluateValueMember(item); var itemText = (EvaluateDisplayMember(item) ?? "").ToString(); var isSelected = (itemValue == null && SelectedValue == null) || itemValue.Equals(SelectedValue); writer.RenderBeginTag("option"); writer.AddAttribute("value", (itemValue ?? "").ToString()); writer.WriteText(itemText, true); if (isSelected) { writer.AddAttribute("selected", "selected"); } writer.RenderEndTag(); } } }
protected override void RenderContents(IHtmlWriter writer, RenderContext context) { if (RenderOnServer) { if (!string.IsNullOrWhiteSpace(EmptyItemText)) { writer.RenderBeginTag("option"); writer.WriteText(EmptyItemText); writer.RenderEndTag(); } } base.RenderContents(writer, context); }
protected override void RenderInputTag(IHtmlWriter writer) { writer.AddStyleAttribute("width", "150px"); writer.AddStyleAttribute("height", "155px"); writer.AddStyleAttribute("display", "inline-flex"); writer.RenderBeginTag("div"); RenderCheckbox(writer); RenderCheckboxPicture(writer); RenderNotPicked(writer); RenderPicked(writer); writer.RenderEndTag(); }
/// <summary> /// Renders the resource in the specified <see cref="IHtmlWriter" />. /// </summary> public override void Render(IHtmlWriter writer, string friendlyName = null) { if (CdnUrl != null) { writer.AddAttribute("src", CdnUrl); writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.RenderEndTag(); if (Url != null && GlobalObjectName != null) { writer.RenderBeginTag("script"); writer.WriteUnencodedText(string.Format(CdnFallbackScript, GlobalObjectName, GetUrl(friendlyName))); writer.RenderEndTag(); } } else if (Url != null) { writer.AddAttribute("src", GetUrl(friendlyName)); writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.RenderEndTag(); } }
/// <summary> /// Renders the resource in the specified <see cref="IHtmlWriter" />. /// </summary> public override void Render(IHtmlWriter writer) { if (CdnUrl != null) { writer.AddAttribute("src", CdnUrl); writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.RenderEndTag(); if (Url != null && GlobalObjectName != null) { writer.RenderBeginTag("script"); writer.WriteUnencodedText(string.Format(CdnFallbackScript, GlobalObjectName, GetUrl())); writer.RenderEndTag(); } } else if (Url != null) { writer.AddAttribute("src", GetUrl()); writer.AddAttribute("type", "text/javascript"); writer.RenderBeginTag("script"); writer.RenderEndTag(); } }
protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context) { // render the header head?.Render(writer, context); // render body if (!RenderOnServer) { writer.AddKnockoutForeachDataBind("dotvvm.evaluator.getDataSourceItems($gridViewDataSet)"); } writer.RenderBeginTag("tbody"); // render contents if (RenderOnServer) { // render on server var index = 0; foreach (var child in Children.Except(new[] { head !, emptyDataContainer ! }))
/// <summary> /// Renders the control into the specified writer. /// </summary> protected override void RenderControl(IHtmlWriter writer, RenderContext context) { // render resource links var resources = context.ResourceManager.GetResourcesInOrder().Where(r => r.GetRenderPosition() == ResourceRenderPosition.Body); foreach (var resource in resources) { resource.Render(writer); } // render the serialized viewmodel var serializedViewModel = context.RequestContext.GetSerializedViewModel(); writer.AddAttribute("type", "hidden"); writer.AddAttribute("id", "__rw_viewmodel_" + context.CurrentPageArea); writer.AddAttribute("value", serializedViewModel); writer.RenderSelfClosingTag("input"); // init on load writer.RenderBeginTag("script"); writer.WriteUnencodedText(string.Format("redwood.onDocumentReady(function () {{ redwood.init('{0}', '{1}'); }});", context.CurrentPageArea, Thread.CurrentThread.CurrentUICulture.Name)); writer.RenderEndTag(); }
protected override void RenderControl(IHtmlWriter writer) { writer.RenderBeginTag("input"); var expr = KnockoutBindingHelper.GetBindingExpressionOrNull(TextProperty, this); if (KnockoutBindingHelper.IsKnockoutBinding(expr)) { writer.AddBindingAttribute("value", KnockoutBindingHelper.TranslateToKnockoutProperty(this, TextProperty, expr)); } else { writer.AddAttribute("value", Text); } var expr2 = KnockoutBindingHelper.GetCommandExpressionOrNull(OnClickProperty, this); if (KnockoutBindingHelper.IsKnockoutCommand(expr2)) { writer.AddBindingAttribute("click", KnockoutBindingHelper.TranslateToKnockoutCommand(this, OnClickProperty, expr2)); } writer.AddAttribute("type", "button"); writer.RenderEndTag(); }
/// <summary> /// Renders the control into the specified writer. /// </summary> protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context) { // render resource links var resources = context.ResourceManager.GetResourcesInOrder().Where(r => r.GetRenderPosition() == ResourceRenderPosition.Body); foreach (var resource in resources) { resource.Render(writer, context); } // render the serialized viewmodel var serializedViewModel = ((DotvvmRequestContext) context).GetSerializedViewModel(); writer.AddAttribute("type", "hidden"); writer.AddAttribute("id", "__dot_viewmodel_root"); writer.AddAttribute("value", serializedViewModel); writer.RenderSelfClosingTag("input"); // init on load writer.RenderBeginTag("script"); writer.WriteUnencodedText($@" window.dotvvm.domUtils.onDocumentReady(function () {{ window.dotvvm.init('root', '{Thread.CurrentThread.CurrentUICulture.Name}'); }});"); writer.RenderEndTag(); }
protected override void RenderBeginTag(IHtmlWriter writer, RenderContext context) { writer.RenderBeginTag("div"); base.RenderBeginTag(writer, context); }
/// <summary> /// Renders the control begin tag. /// </summary> protected override void RenderBeginTag(IHtmlWriter writer, RenderContext context) { writer.RenderBeginTag(TagName); }
protected override void RenderContents(IHtmlWriter writer, RenderContext context) { if (Children.Count == 0) return; // render the header Children[0].Render(writer, context); // render body var dataSourceBinding = GetDataSourceBinding(); if (!RenderOnServer) { var expression = dataSourceBinding.TranslateToClientScript(this, DataSourceProperty); writer.AddKnockoutForeachDataBind(expression); } writer.RenderBeginTag("tbody"); // render contents if (RenderOnServer) { // render on server var index = 0; foreach (var child in Children.Skip(1)) { context.PathFragments.Push(dataSourceBinding.GetViewModelPathExpression(this, DataSourceProperty) + "[" + index + "]"); Children[index].Render(writer, context); context.PathFragments.Pop(); index++; } } else { // render on client for (var i = Children.Count - 1; i > 0; i--) { Children.RemoveAt(i); } var placeholder = new DataItemContainer(); placeholder.SetValue(Internal.IsDataContextBoundaryProperty, true); Children.Add(placeholder); CreateRow(context.RequestContext, placeholder); context.PathFragments.Push(dataSourceBinding.GetViewModelPathExpression(this, DataSourceProperty) + "[$index]"); placeholder.Render(writer, context); context.PathFragments.Pop(); } writer.RenderEndTag(); }
protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context) { if (HasValueBinding(EnabledProperty)) writer.WriteKnockoutDataBindComment("dotvvm_introduceAlias", $"{{ '$pagerEnabled': { GetValueBinding(EnabledProperty).GetKnockoutBindingExpression() }}}"); if (HideWhenOnlyOnePage) { writer.AddKnockoutDataBind("visible", "ko.unwrap(" + GetDataSetBinding().GetKnockoutBindingExpression() + ").PagesCount() > 1"); } writer.AddKnockoutDataBind("with", this, DataSetProperty, renderEvenInServerRenderingMode: true); writer.RenderBeginTag("ul"); }
/// <summary> /// Renders the children. /// </summary> protected override void RenderControl(IHtmlWriter writer, RenderContext context) { // label var textBinding = GetBinding(TextProperty); var labelRequired = textBinding != null || !string.IsNullOrEmpty(Text) || !HasOnlyWhiteSpaceContent(); if (labelRequired) { writer.RenderBeginTag("label"); } // prepare changed event attribute var changedBinding = GetCommandBinding(ChangedProperty); if (changedBinding != null) { writer.AddAttribute("onclick", KnockoutHelper.GenerateClientPostBackScript(changedBinding, context, this, true, true)); } // handle enabled attribute writer.AddKnockoutDataBind("enable", this, EnabledProperty, () => { if (!Enabled) { writer.AddAttribute("disabled", "disabled"); } }); // add ID AddControlIdAttribute(writer); // render the radio button RenderInputTag(writer); // render the label if (labelRequired) { if (textBinding != null) { writer.AddKnockoutDataBind("text", this, TextProperty, () => { }); writer.RenderBeginTag("span"); writer.RenderEndTag(); } else if (!string.IsNullOrEmpty(Text)) { writer.WriteText(Text); } else if (!HasOnlyWhiteSpaceContent()) { RenderChildren(writer, context); } writer.RenderEndTag(); } }
/// <summary> /// Renders the control into the specified writer. /// </summary> protected override void RenderControl(IHtmlWriter writer, RenderContext context) { var textBinding = GetBinding(TextProperty); if (textBinding != null && !RenderOnServer && textBinding.Javascript != null) { var expression = textBinding.Javascript; if (!string.IsNullOrEmpty(FormatString)) { expression = "dotvvm.formatString(" + JsonConvert.SerializeObject(FormatString) + ", " + expression + ")"; } writer.AddKnockoutDataBind(HtmlEncode ? "text" : "html", expression); AddAttributesToRender(writer, context); writer.RenderBeginTag("span"); writer.RenderEndTag(); } else { if (AlwaysRenderSpan) { AddAttributesToRender(writer, context); writer.RenderBeginTag("span"); } var textToDisplay = ""; if (!string.IsNullOrEmpty(FormatString)) { textToDisplay = string.Format("{0:" + FormatString + "}", GetValue(TextProperty)); } else { textToDisplay = GetValue(TextProperty)?.ToString() ?? ""; } if (HtmlEncode) { writer.WriteText(textToDisplay); } else { writer.WriteUnencodedText(textToDisplay); } if (AlwaysRenderSpan) { writer.RenderEndTag(); } } }
private void RenderUploadButton(IHtmlWriter writer) { // render upload button writer.AddAttribute("class", "dotvvm-upload-button"); writer.AddKnockoutDataBind("visible", "!IsBusy()"); writer.RenderBeginTag("span"); writer.AddAttribute("href", "#"); writer.AddAttribute("onclick", "dotvvm.fileUpload.showUploadDialog(this); return false;"); writer.RenderBeginTag("a"); writer.WriteUnencodedText(UploadButtonText); writer.RenderEndTag(); writer.RenderEndTag(); }
protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context) { // render the header head?.Render(writer, context); // render body if (!RenderOnServer) { writer.AddKnockoutForeachDataBind("dotvvm.evaluator.getDataSourceItems($gridViewDataSet)"); } writer.RenderBeginTag("tbody"); // render contents if (RenderOnServer) { // render on server var index = 0; foreach (var child in Children.Except(new[] { head, emptyDataContainer })) { child.Render(writer, context); index++; } } else { // render on client if (InlineEditing) { var placeholder = new DataItemContainer { DataContext = null }; placeholder.SetValue(Internal.PathFragmentProperty, JavascriptCompilationHelper.AddIndexerToViewModel(GetPathFragmentExpression(), "$index")); placeholder.SetValue(Internal.ClientIDFragmentProperty, "$index()"); writer.WriteKnockoutDataBindComment("if", "ko.unwrap(ko.unwrap($gridViewDataSet).EditRowId) !== ko.unwrap($data[ko.unwrap(ko.unwrap($gridViewDataSet).PrimaryKeyPropertyName)])"); CreateTemplates(context, placeholder); Children.Add(placeholder); placeholder.Render(writer, context); writer.WriteKnockoutDataBindEndComment(); var placeholderEdit = new DataItemContainer { DataContext = null }; placeholderEdit.SetValue(Internal.PathFragmentProperty, JavascriptCompilationHelper.AddIndexerToViewModel(GetPathFragmentExpression(), "$index")); placeholderEdit.SetValue(Internal.ClientIDFragmentProperty, "$index()"); writer.WriteKnockoutDataBindComment("if", "ko.unwrap(ko.unwrap($gridViewDataSet).EditRowId) === ko.unwrap($data[ko.unwrap(ko.unwrap($gridViewDataSet).PrimaryKeyPropertyName)])"); CreateTemplates(context, placeholderEdit, true); Children.Add(placeholderEdit); placeholderEdit.Render(writer, context); writer.WriteKnockoutDataBindEndComment(); } else { var placeholder = new DataItemContainer { DataContext = null }; placeholder.SetValue(Internal.PathFragmentProperty, JavascriptCompilationHelper.AddIndexerToViewModel(GetPathFragmentExpression(), "$index")); placeholder.SetValue(Internal.ClientIDFragmentProperty, "$index()"); CreateRowWithCells(context, placeholder); Children.Add(placeholder); placeholder.Render(writer, context); } } writer.RenderEndTag(); }
/// <summary> /// Renders the control begin tag. /// </summary> protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context) { if (RendersHtmlTag) writer.RenderBeginTag(TagName); }
/// <summary> /// Renders the control into the specified writer. /// </summary> protected override void RenderControl(IHtmlWriter writer, RenderContext context) { var textBinding = GetBinding(TextProperty); if (textBinding != null && !RenderOnServer) { var expression = textBinding.TranslateToClientScript(this, TextProperty); if (!string.IsNullOrEmpty(FormatString)) { expression = "redwood.formatString(" + JsonConvert.SerializeObject(FormatString) + ", " + expression + ")"; } writer.AddKnockoutDataBind(HtmlEncode ? "text" : "html", expression); writer.RenderBeginTag("span"); writer.RenderEndTag(); } else { var textToDisplay = Text; if (!string.IsNullOrEmpty(FormatString)) { textToDisplay = string.Format("{0:" + FormatString + "}", textToDisplay); } if (HtmlEncode) { writer.WriteText(textToDisplay); } else { writer.WriteUnencodedText(textToDisplay); } } }
protected override void RenderBeginTag(IHtmlWriter writer, RenderContext context) { writer.AddKnockoutDataBind("with", this, DataSetProperty, () => { }); writer.AddKnockoutDataBind("visible", "ko.unwrap(" + GetDataSetBinding().GetKnockoutBindingExpression() + ").TotalItemsCount() > 0"); writer.RenderBeginTag("ul"); }