コード例 #1
0
        private IEnumerable <HElement> GetPageContents(SessionData sessionData, string subUrl)
        {
            yield return(new HHeadline("Directoy Responses"));

            if (string.IsNullOrEmpty(subUrl))
            {
                yield return(new HText($"Directoy Responses are called for all request targeting a specific sub-directory like '{URL}/<suburl>' for this {nameof(DirectoryElementResponse)}."));

                yield return(new HText($"Enter a suburl to visit:"));

                // Create a text-field that changes the sub-url, a button should go to on click.
                JSVariable suburl = new JSVariable();
                JSButton   button = new JSButton("Go to Sub-URL");
                button.onclick = new JScript(JSValue.CurrentBrowserURL.Set(new JSStringValue($"{URL}/") + suburl.Name));

                JSInput input = new JSInput(HInput.EInputType.text, "suburl");
                input.onchange = new JScript(suburl.Set(input.GetInnerValue()));

                yield return(new HContainer(new HScript(suburl.GetJsCode(sessionData)), input, button)
                {
                    Class = "fit"
                });
            }
            else
            {
                yield return(new HHeadline($"Sub-URL '{subUrl}' has been called.", 3));

                yield return(new HTextBlock($"You can return to the main-page of this {nameof(DirectoryElementResponse)} by clicking ", new HLink("here", "/" + URL)
                {
                    Style = "display: initial;"
                }, "."));
            }
        }
コード例 #2
0
        /// <inheritdoc />
        public override string GetContent(SessionData sessionData)
        {
            var input = new JSInput(HInput.EInputType.text, Name, Value)
            {
                Class = Class, Style = Style, Title = Title
            };

            if (!string.IsNullOrWhiteSpace(Placeholder))
            {
                input.DescriptionTags = "placeholder='" + Placeholder + "' ";
            }

            if (!string.IsNullOrWhiteSpace(ID))
            {
                input.ID = ID;
            }
            else
            {
                input.ID = Hash.GetHash();
            }

            var container = new HContainer()
            {
                ID = ContainerID, Style = "display:none;"
            };

            input.onclick    = JSFunctionCall.DisplayElementByID(container.ID);
            input.onfocus    = input.onclick;
            input.oninput    = input.SetInnerHTMLWithNameValueAsync(JSElement.GetByID(container.ID), "/" + _pageUrl, JSFunctionCall.DisplayElementByID(container.ID));
            input.onfocusout = new JSIf(JSElement.GetByID(input.ID)["value"].IsEqualTo(new JSRawStringValue("")), JSFunctionCall.HideElementByID(container.ID));

            return(input + container);
        }