コード例 #1
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);
                }
            }
        }
コード例 #2
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            writer.WriteUnencodedText(ClientTimingHelper.InitScript);

            if (StackExchange.Profiling.MiniProfiler.Current is object)
            {
#if AspNetCore
                var html = StackExchange.Profiling.MiniProfiler.Current.RenderIncludes(
                    context.GetAspNetCoreContext(),
                    position: Position,
                    showTrivial: ShowTrivial,
                    showTimeWithChildren: ShowTimeWithChildren,
                    maxTracesToShow: MaxTraces,
                    showControls: ShowControls,
                    startHidden: StartHidden);
#else
                var html = StackExchange.Profiling.MiniProfiler.Current.RenderIncludes(
                    position: Position,
                    showTrivial: ShowTrivial,
                    showTimeWithChildren: ShowTimeWithChildren,
                    maxTracesToShow: MaxTraces,
                    showControls: ShowControls,
                    startHidden: StartHidden);
#endif
                writer.WriteUnencodedText(html.ToString());
            }

            base.RenderControl(writer, context);
        }
コード例 #3
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();
        }
コード例 #4
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();
            }
        }
コード例 #5
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();
 }
コード例 #6
0
        /// <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();
            }
        }
コード例 #7
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();
        }
コード例 #8
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();
        }
コード例 #9
0
 protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     if (RenderOnServer || !HasValueBinding(HtmlProperty))
     {
         writer.WriteUnencodedText(Html);
     }
 }
コード例 #10
0
 public virtual void WriteUnencodedText(string text)
 {
     if (StartTagSkipped)
     {
         return;
     }
     writer.WriteUnencodedText(text);
 }
コード例 #11
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();
 }
コード例 #12
0
ファイル: KnockoutHelper.cs プロジェクト: vijayaraju/dotvvm
        public static void WriteKnockoutDataBindComment(this IHtmlWriter writer, string name, string expression)
        {
            if (name.Contains("-->") || expression.Contains("-->"))
            {
                throw new Exception("Knockout data bind comment can't contain substring '-->'. If you have discovered this exception in your log, you probably have a XSS vulnerability in you website.");
            }

            writer.WriteUnencodedText($"<!-- ko { name }: { expression } -->");
        }
コード例 #13
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();
 }
コード例 #14
0
        static void WriteResourceInfo(NamedResource resource, IHtmlWriter writer, bool preload)
        {
            var comment = $"Resource {resource.Name} of type {resource.Resource.GetType().Name}.";

            if (resource.Resource is ILinkResource linkResource)
            {
                comment += $" Pointing to {string.Join(", ", linkResource.GetLocations().Select(l => l.GetType().Name))}.";
            }

            if (preload)
            {
                comment = "[preload link] " + comment;
            }

            writer.WriteUnencodedText("\n    <!-- ");
            writer.WriteText(comment);
            writer.WriteUnencodedText(" -->\n    ");
            //                               ^~~~ most likely this info will be written directly in the <body> or <head>, so it should be indented by one level.
            //                                    we don't have any better way to know how we should indent
        }
コード例 #15
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();
            }
        }
コード例 #16
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();
        }
コード例 #17
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.WriteUnencodedText(UploadButtonText);
     writer.RenderEndTag();
     writer.RenderEndTag();
 }
コード例 #18
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            var html = StackExchange.Profiling.MiniProfiler.RenderIncludes(
                position: Position,
                showTrivial: ShowTrivial,
                showTimeWithChildren: ShowTimeWithChildren,
                maxTracesToShow: MaxTraces,
                showControls: ShowControls,
                startHidden: StartHidden);

            writer.WriteUnencodedText(html.ToString());

            base.RenderControl(writer, context);
        }
コード例 #19
0
        protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            var parameters = new RouteValueDictionary();

            foreach (var param in Params.RawValues)
            {
                var value = param.Value is IValueBinding ? ((IValueBinding)param.Value).Evaluate(this) : param.Value;
                parameters.Add(param.Key, value);
            }

            var w = new StringWriter();

            Task.Run(async() => await mvcUtility.RenderView(ControllerName, ViewName, parameters, Model, w)).Wait();
            writer.WriteUnencodedText(w.ToString());
        }
コード例 #20
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            var doNotTrack = false;

            if (context.HttpContext.Request.Headers.TryGetValue("DNT", out var doNotTrackHeaderValue))
            {
                doNotTrack = string.Equals(doNotTrackHeaderValue, "1");
            }

            if (!doNotTrack)
            {
                writer.WriteUnencodedText(RenderSnippet(context.HttpContext));
            }

            base.RenderControl(writer, context);
        }
コード例 #21
0
        protected override void RenderContents(IHtmlWriter writer, RenderContext context)
        {
            // render iframe
            writer.AddAttribute("class", "dot-upload-iframe");
            writer.AddAttribute("src", "~/" + Constants.FileUploadHandlerMatchUrl + (AllowMultipleFiles ? "?multiple=true" : ""));
            writer.RenderBeginTag("iframe");
            writer.RenderEndTag();

            // render upload button
            writer.AddAttribute("class", "dot-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();

            // render upload files
            writer.AddAttribute("class", "dot-upload-files");
            writer.AddKnockoutDataBind("html", $"dotvvm.globalize.format({JsonConvert.SerializeObject(NumberOfFilesIndicatorText)}, Files().length)");
            writer.RenderBeginTag("span");
            writer.RenderEndTag();

            // render progress wrapper
            writer.AddKnockoutDataBind("visible", "IsBusy");
            writer.AddAttribute("class", "dot-upload-progress-wrapper");
            writer.RenderBeginTag("span");
            writer.AddAttribute("class", "dot-upload-progress");
            writer.AddKnockoutDataBind("style", "{ 'width': (Progress() == -1 ? '50' : Progress()) + '%' }");
            writer.RenderBeginTag("span");
            writer.RenderEndTag();
            writer.RenderEndTag();

            // render result
            writer.AddAttribute("class", "dot-upload-result");
            writer.AddKnockoutDataBind("html", $"Error() ? {JsonConvert.SerializeObject(UploadErrorMessageText)} : {JsonConvert.SerializeObject(SuccessMessageText)}");
            writer.AddKnockoutDataBind("attr", "{ title: Error }");
            writer.AddKnockoutDataBind("css", "{ 'dot-upload-result-success': !Error(), 'dot-upload-result-error': Error }");
            writer.AddKnockoutDataBind("visible", "!IsBusy() && Files().length > 0");
            writer.RenderBeginTag("span");
            writer.RenderEndTag();

            base.RenderContents(writer, context);
        }
コード例 #22
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            var doNotTrack = false;

            if (context.HttpContext.Request.Headers.TryGetValue("DNT", out var doNotTrackHeaderValue))
            {
                doNotTrack = string.Equals(doNotTrackHeaderValue, "1");
            }

            if (!doNotTrack)
            {
                var javascriptSnippet = context.Services.GetRequiredService <JavaScriptSnippet>();

                writer.WriteUnencodedText(javascriptSnippet.FullScript);
            }

            base.RenderControl(writer, context);
        }
コード例 #23
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            var doNotTrack = false;

            if (context.HttpContext.Request.Headers.TryGetValue("DNT", out var doNotTrackHeaderValue))
            {
                doNotTrack = string.Equals(doNotTrackHeaderValue, "1");
            }

            if (!doNotTrack)
            {
                var javascriptSnippet = new JavaScriptSnippet(telemetryConfiguration.Value, applicationInsightsServiceOptions, httpContextAccessor);

                writer.WriteUnencodedText(javascriptSnippet.FullScript);
            }

            base.RenderControl(writer, context);
        }
コード例 #24
0
ファイル: LinkResourceBase.cs プロジェクト: vstribrny/dotvvm
 public override void Render(IHtmlWriter writer, IDotvvmRequestContext context, string resourceName)
 {
     RenderLink(Location, writer, context, resourceName);
     if (LocationFallback != null)
     {
         foreach (var fallback in LocationFallback.AlternativeLocations)
         {
             var link = RenderLinkToString(fallback, context, resourceName);
             if (!string.IsNullOrEmpty(link))
             {
                 writer.AddAttribute("type", "text/javascript");
                 writer.RenderBeginTag("script");
                 writer.WriteUnencodedText($"{LocationFallback.JavascriptCondition} || document.write({JsonConvert.ToString(link, '\'').Replace("<", "\\u003c")})");
                 writer.RenderEndTag();
             }
         }
     }
 }
コード例 #25
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();
        }
コード例 #26
0
        public override void Render(IHtmlWriter writer, IDotvvmRequestContext context, string resourceName)
        {
            if (this.code == null)
            {
                var newCode = new Lazy <string>(() => {
                    var c = resourceLocation !.ReadToString(context);
                    InlineStyleContentGuard(c);
                    return(c);
                });
                // assign the `newValue` into `this.code` iff it's still null
                Interlocked.CompareExchange(ref this.code, value: newCode, comparand: null);
            }
            var code = this.code.Value;

            if (!string.IsNullOrWhiteSpace(code))
            {
                writer.RenderBeginTag("style");
                writer.WriteUnencodedText(code);
                writer.RenderEndTag();
            }
        }
コード例 #27
0
        protected override void RenderControl(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            var doNotTrack = false;

            if (context.HttpContext.Request.Headers.TryGetValue("DNT", out var doNotTrackHeaderValue))
            {
                doNotTrack = string.Equals(doNotTrackHeaderValue, "1");
            }

            if (!doNotTrack)
            {
                var options = ResolveOptions(context);

                string additionalJS = options.PageViewEnabled ? PageViewJavascriptSnippet :string.Empty;

                var snippet = options.AsyncVersionEnabled ? AsyncJavascriptSnippet : JavascriptSnippet;
                var script  = string.Format(snippet, options.TrackingId, additionalJS);

                writer.WriteUnencodedText(script);
            }

            base.RenderControl(writer, context);
        }
コード例 #28
0
ファイル: LinkResourceBase.cs プロジェクト: vnwonah/dotvvm
        public override void Render(IHtmlWriter writer, IDotvvmRequestContext context, string resourceName)
        {
            RenderLink(Location, writer, context, resourceName);
            if (LocationFallback != null)
            {
                if (Location is ILocalResourceLocation &&
                    LocationFallback.AlternativeLocations.Count > 0)
                {
                    throw new NotSupportedException("LocationFallback is not supported on " +
                                                    "resources with Location of type ILocalResourceLocation.");
                }

                foreach (var fallback in LocationFallback.AlternativeLocations)
                {
                    var link = RenderLinkToString(fallback, context, resourceName);
                    if (!string.IsNullOrEmpty(link))
                    {
                        writer.AddAttribute("type", "text/javascript");
                        writer.RenderBeginTag("script");
                        var script = JsonConvert.ToString(link, '\'').Replace("<", "\\u003c");
                        writer.WriteUnencodedText(
                            $@"if (!({LocationFallback.JavascriptCondition})) {{
    var wrapper = document.createElement('div');
    wrapper.innerHTML = {script};
    var originalScript = wrapper.children[0];
    var script = document.createElement('script');
    script.src = originalScript.src;
    script.type = originalScript.type;
    script.text = originalScript.text;
    script.id = originalScript.id;
    document.head.appendChild(script);
}}");
                        writer.RenderEndTag();
                    }
                }
            }
        }
コード例 #29
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();
        }
コード例 #30
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();
            }
        }
コード例 #31
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();
            }
        }
コード例 #32
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();
                }
            }
        }
コード例 #33
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();
 }
コード例 #34
0
 protected override void RenderContents(IHtmlWriter writer, RenderContext context)
 {
     writer.WriteUnencodedText(Text);
 }
コード例 #35
0
ファイル: RawLiteral.cs プロジェクト: darilek/dotvvm
 public override void Render(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     writer.WriteUnencodedText(EncodedText);
 }
コード例 #36
0
ファイル: HtmlLiteral.cs プロジェクト: darilek/dotvvm
 protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
 {
     if (RenderOnServer || !HasBinding(HtmlProperty))
     {
         writer.WriteUnencodedText(Html);       
     }
 }
コード例 #37
0
 public static void WriteKnockoutDataBindComment(this IHtmlWriter writer, string name, string expression)
 {
     writer.WriteUnencodedText($"<!-- ko { name }: { expression } -->");
 }
コード例 #38
0
ファイル: FileUpload.cs プロジェクト: adamjez/dotvvm
        protected override void RenderContents(IHtmlWriter writer, RenderContext context)
        {
            // render iframe
            writer.AddAttribute("class", "rw-upload-iframe");
            writer.AddAttribute("src", "~/" + Constants.FileUploadHandlerMatchUrl + (AllowMultipleFiles ? "?multiple=true" : ""));
            writer.AddAttribute("id", ID + "_iframe");
            writer.AddAttribute("data-target-control-id", ID);
            writer.RenderBeginTag("iframe");
            writer.RenderEndTag();

            // render upload button
            writer.AddAttribute("class", "rw-upload-button");
            writer.AddKnockoutDataBind("visible", "!IsBusy()");
            writer.RenderBeginTag("span");
            writer.AddAttribute("href", "#");
            writer.AddAttribute("onclick", string.Format("redwood.fileUpload.showUploadDialog('{0}_iframe'); return false;", ID));
            writer.RenderBeginTag("a");
            writer.WriteUnencodedText("Upload");     // TODO: localization
            writer.RenderEndTag();
            writer.RenderEndTag();

            // render upload files
            writer.AddAttribute("class", "rw-upload-files");
            writer.AddKnockoutDataBind("html", "redwood.format('{0} files', Files().length)");     // TODO: localization
            writer.RenderBeginTag("span");
            writer.RenderEndTag();

            // render progress wrapper
            writer.AddKnockoutDataBind("visible", "IsBusy");
            writer.AddAttribute("class", "rw-upload-progress-wrapper");
            writer.RenderBeginTag("span");
            writer.AddAttribute("class", "rw-upload-progress");
            writer.AddKnockoutDataBind("style", "{ 'width': (Progress() == -1 ? '50' : Progress()) + '%' }");
            writer.RenderBeginTag("span");
            writer.RenderEndTag();
            writer.RenderEndTag();

            // render result
            writer.AddAttribute("class", "rw-upload-result");
            writer.AddKnockoutDataBind("html", "Error() ? 'Error occured.' : 'The files are uploaded.'");       // TODO: localization
            writer.AddKnockoutDataBind("attr", "{ title: Error }");
            writer.AddKnockoutDataBind("css", "{ 'rw-upload-result-success': !Error(), 'rw-upload-result-error': Error }");
            writer.AddKnockoutDataBind("visible", "!IsBusy() && Files().length > 0");
            writer.RenderBeginTag("span");
            writer.RenderEndTag();

            base.RenderContents(writer, context);
        }
コード例 #39
0
ファイル: ServerRenderedLabel.cs プロジェクト: holajan/dotvvm
 protected override void RenderContents(IHtmlWriter writer, RenderContext context)
 {
     writer.WriteUnencodedText(Text);
 }
コード例 #40
0
 public static void RenderResourceCached(this NamedResource resource, IHtmlWriter writer, IDotvvmRequestContext context)
 {
     writer.WriteUnencodedText(resource.GetRenderedTextCached(context));
 }
コード例 #41
0
 public static void WriteKnockoutDataBindComment(this IHtmlWriter writer, string name, DotvvmControl control, DotvvmProperty property)
 {
     writer.WriteUnencodedText($"<!-- ko { name }: { control.GetValueBinding(property).GetKnockoutBindingExpression() } -->");
 }
コード例 #42
0
        protected override void RenderContents(IHtmlWriter writer, IDotvvmRequestContext context)
        {
            var html = CommonMarkConverter.Convert(Markdown);

            writer.WriteUnencodedText(html);
        }
コード例 #43
0
ファイル: KnockoutHelper.cs プロジェクト: vijayaraju/dotvvm
 public static void WriteKnockoutDataBindEndComment(this IHtmlWriter writer)
 {
     writer.WriteUnencodedText("<!-- /ko -->");
 }
コード例 #44
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);
                }
            }
        }