コード例 #1
0
ファイル: ScriptResource.cs プロジェクト: darilek/dotvvm
        /// <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();
            }
        }
コード例 #2
0
ファイル: TextBox.cs プロジェクト: jechtom/Redwood
        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();
        }
コード例 #3
0
ファイル: Table.cs プロジェクト: jechtom/Redwood
        /// <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();
        }
コード例 #4
0
ファイル: FileUpload.cs プロジェクト: vijayaraju/dotvvm
 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();
 }
コード例 #5
0
 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();
 }
コード例 #6
0
ファイル: BodyResourceLinks.cs プロジェクト: wushian/dotvvm
        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();
        }
コード例 #7
0
        /// <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);
                }
            }
        }
コード例 #8
0
ファイル: ValidationSummary.cs プロジェクト: darilek/dotvvm
 /// <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();
 }
コード例 #9
0
        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);
        }
コード例 #10
0
        /// <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();
        }
コード例 #11
0
 /// <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();
 }
コード例 #12
0
ファイル: HtmlGenericControl.cs プロジェクト: Ladyia/dotvvm
 /// <summary>
 /// Renders the control begin tag.
 /// </summary>
 protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     if (RendersHtmlTag)
     {
         writer.RenderBeginTag(TagName);
     }
 }
コード例 #13
0
 protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     if (isLabelRequired)
     {
         writer.RenderBeginTag("label");
     }
 }
コード例 #14
0
 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();
 }
コード例 #15
0
 /// <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();
 }
コード例 #16
0
        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();
        }
コード例 #17
0
ファイル: FileUpload.cs プロジェクト: vnwonah/dotvvm
 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();
 }
コード例 #18
0
 private void RenderIframe(IHtmlWriter writer)
 {
     // render iframe
     writer.AddAttribute("class", "dotvvm-upload-iframe");
     writer.AddAttribute("src", GetFileUploadHandlerUrl());
     writer.RenderBeginTag("iframe");
     writer.RenderEndTag();
 }
コード例 #19
0
ファイル: HtmlElement.cs プロジェクト: jechtom/Redwood
 protected override void RenderControl(IHtmlWriter writer)
 {
     writer.RenderBeginTag(Element);
     if (htmlAttributesStorage != null)
         htmlAttributesStorage.Render(writer);
     base.RenderControl(writer);
     writer.RenderEndTag(true);
 }
コード例 #20
0
ファイル: FileUpload.cs プロジェクト: samdubey/dotvvm
 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();
 }
コード例 #21
0
ファイル: FormGroup.cs プロジェクト: adamjez/dotvvm
 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();
     }
 }
コード例 #22
0
 /// <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();
 }
コード例 #23
0
 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();
 }
コード例 #24
0
        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();
        }
コード例 #25
0
 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();
 }
コード例 #26
0
 private void RenderCheckboxPicture(IHtmlWriter writer)
 {
     writer.AddKnockoutDataBind("attr", BuildKnockoutBidningLabelAttributes());
     writer.AddKnockoutDataBind("text", this, NameProperty, () =>
     {
         writer.AddAttribute("text", Name);
     });
     writer.RenderBeginTag("label");
     writer.RenderEndTag();
 }
コード例 #27
0
ファイル: DataPager.cs プロジェクト: kiraacorsac/dotvvm
        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");
        }
コード例 #28
0
ファイル: DataPager.cs プロジェクト: gitter-badger/dotvvm
        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");
        }
コード例 #29
0
ファイル: FormGroup.cs プロジェクト: adamjez/dotvvm
        protected override void RenderContents(IHtmlWriter writer, RenderContext context)
        {
            RenderLabel(writer);

            writer.AddAttribute("class", "col-sm-10");
            writer.RenderBeginTag("div");

            RenderChildren(writer, context);

            writer.RenderEndTag();
        }
コード例 #30
0
 /// <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();
 }
コード例 #31
0
ファイル: RadioButton.cs プロジェクト: jechtom/Redwood
        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();
            }
        }
コード例 #32
0
ファイル: IntegrationScripts.cs プロジェクト: jechtom/Redwood
        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();
        }
コード例 #33
0
 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();
 }
コード例 #34
0
 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();
 }
コード例 #35
0
        /// <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);
            }
        }
コード例 #36
0
ファイル: PolyfillResource.cs プロジェクト: weiplanet/dotvvm
        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();
        }
コード例 #37
0
        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();
            }
        }
コード例 #38
0
 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;
     }
 }
コード例 #39
0
ファイル: DropDownList.cs プロジェクト: jechtom/Redwood
        /// <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();
                }
            }
        }
コード例 #40
0
ファイル: ComboBox.cs プロジェクト: adamjez/dotvvm
        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);
        }
コード例 #41
0
ファイル: ComboBox.cs プロジェクト: gitter-badger/dotvvm
        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);
        }
コード例 #42
0
        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();
        }
コード例 #43
0
ファイル: ScriptResource.cs プロジェクト: holajan/dotvvm
        /// <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();
            }
        }
コード例 #44
0
        /// <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();
            }
        }
コード例 #45
0
ファイル: GridView.cs プロジェクト: vijayaraju/dotvvm
        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 ! }))
コード例 #46
0
ファイル: BodyResourceLinks.cs プロジェクト: adamjez/dotvvm
        /// <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();
        }
コード例 #47
0
ファイル: Button.cs プロジェクト: jechtom/Redwood
        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();
        }
コード例 #48
0
ファイル: BodyResourceLinks.cs プロジェクト: darilek/dotvvm
        /// <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();
        }
コード例 #49
0
 protected override void RenderBeginTag(IHtmlWriter writer, RenderContext context)
 {
     writer.RenderBeginTag("div");
     base.RenderBeginTag(writer, context);
 }
コード例 #50
0
ファイル: HtmlGenericControl.cs プロジェクト: adamjez/dotvvm
 /// <summary>
 /// Renders the control begin tag.
 /// </summary>
 protected override void RenderBeginTag(IHtmlWriter writer, RenderContext context)
 {
     writer.RenderBeginTag(TagName);
 }
コード例 #51
0
ファイル: GridView.cs プロジェクト: adamjez/dotvvm
        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();
        }
コード例 #52
0
ファイル: DataPager.cs プロジェクト: darilek/dotvvm
        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");
        }
コード例 #53
0
        /// <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();
            }
        }
コード例 #54
0
ファイル: Literal.cs プロジェクト: holajan/dotvvm
        /// <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();
                }
            }
        }
コード例 #55
0
ファイル: FileUpload.cs プロジェクト: darilek/dotvvm
 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();
 }
コード例 #56
0
ファイル: FileUpload.cs プロジェクト: darilek/dotvvm
 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();
 }
コード例 #57
0
ファイル: GridView.cs プロジェクト: darilek/dotvvm
        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();
        }
コード例 #58
0
ファイル: HtmlGenericControl.cs プロジェクト: darilek/dotvvm
 /// <summary>
 /// Renders the control begin tag.
 /// </summary>
 protected override void RenderBeginTag(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     if (RendersHtmlTag) writer.RenderBeginTag(TagName);
 }
コード例 #59
0
ファイル: Literal.cs プロジェクト: adamjez/dotvvm
        /// <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);
                }
            }
        }
コード例 #60
0
ファイル: DataPager.cs プロジェクト: holajan/dotvvm
 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");
 }