コード例 #1
0
        void ControlTreeDataLoader.LoadData()
        {
            EwfPage.Instance.AddDisplayLink(this);

            // NOTE: Currently this hidden field will always be persisted in page state whether the page cares about that or not. We should put this decision into the
            // hands of the page, maybe by making ToggleButton sort of like a form control such that it takes a boolean value in its constructor and allows access to
            // its post back value.
            var controlsToggled = false;

            EwfHiddenField.Create(
                this,
                EwfPage.Instance.PageState.GetValue(this, pageStateKey, false).ToString(),
                postBackValue => controlsToggled = getControlsToggled(postBackValue),
                EwfPage.Instance.DataUpdate,
                out controlsToggledHiddenFieldValueGetter,
                out controlsToggledHiddenFieldClientIdGetter);
            EwfPage.Instance.DataUpdate.AddModificationMethod(
                () => AppRequestState.AddNonTransactionalModificationMethod(() => EwfPage.Instance.PageState.SetValue(this, pageStateKey, controlsToggled)));

            if (TagKey == HtmlTextWriterTag.Button)
            {
                PostBackButton.AddButtonAttributes(this);
            }
            this.AddJavaScriptEventScript(JsWritingMethods.onclick, handlerName + "()");
            CssClass    = CssClass.ConcatenateWithSpace("ewfClickable");
            textControl = ActionControlStyle.SetUpControl(this, "", width, height, w => base.Width = w);
        }
コード例 #2
0
        void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                if (TagKey == HtmlTextWriterTag.Button)
                {
                    Attributes.Add("name", EwfPage.ButtonElementName);
                    Attributes.Add("value", "v");
                    Attributes.Add("type", usesSubmitBehavior ? "submit" : "button");
                }

                FormAction action = postBackAction;
                action.AddToPageIfNecessary();

                if (ConfirmationWindowContentControl != null)
                {
                    if (usesSubmitBehavior)
                    {
                        throw new ApplicationException("PostBackButton cannot be the submit button and also have a confirmation message.");
                    }
                    confirmationWindow = new ModalWindow(this, ConfirmationWindowContentControl, title: "Confirmation", postBack: postBackAction.PostBack);
                }
                else if (!usesSubmitBehavior)
                {
                    PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, action.GetJsStatements() + " return false"); }
                }
                ;

                CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
                ActionControlStyle.SetUpControl(this, "");
            });
        }
コード例 #3
0
 /// <summary>
 /// Creates a link.
 /// </summary>
 /// <param name="navigatePageInfo">Where to navigate. Specify null if you don't want the link to do anything.</param>
 /// <param name="actionControlStyle">Choices are: TextActionControlStyle, ImageActionControlStyle, ButtonActionControlStyle, CustomActionControlStyle, and BoxActionControlStyle.</param>
 /// <param name="toolTipText">EWF ToolTip to display on this control. Setting ToolTipControl will ignore this property.</param>
 /// <param name="toolTipControl">Control to display inside the tool tip. Do not pass null. This will ignore the ToolTip property.</param>
 public static EwfLink Create(ResourceInfo navigatePageInfo, ActionControlStyle actionControlStyle, string toolTipText = null, Control toolTipControl = null)
 {
     return(new EwfLink(navigatePageInfo)
     {
         ActionControlStyle = actionControlStyle, toolTip = toolTipText, toolTipControl = toolTipControl
     });
 }
コード例 #4
0
        /// <summary>
        /// Creates a custom button. A semicolon will be added to the end of the script.
        /// </summary>
        public CustomButton(Func <string> scriptGetter)
        {
            ActionControlStyle = new ButtonActionControlStyle("");

            // Defer script generation until after all controls have IDs.
            PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, scriptGetter()); };
        }
コード例 #5
0
        void ControlTreeDataLoader.LoadData()
        {
            if (TagKey == HtmlTextWriterTag.Button)
            {
                Attributes.Add("name", EwfPage.ButtonElementName);
                Attributes.Add("value", "v");
                Attributes.Add("type", usesSubmitBehavior ? "submit" : "button");
            }

            EwfPage.Instance.AddPostBack(postBack);

            if (ConfirmationWindowContentControl != null)
            {
                if (usesSubmitBehavior)
                {
                    throw new ApplicationException("PostBackButton cannot be the submit button and also have a confirmation message.");
                }
                confirmationWindow = new ModalWindow(ConfirmationWindowContentControl, title: "Confirmation", postBack: postBack);
            }
            else if (!usesSubmitBehavior)
            {
                PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, GetPostBackScript(postBack)); }
            }
            ;

            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            ActionControlStyle.SetUpControl(this, "", width, height, setWidth);
        }
コード例 #6
0
 string ControlWithJsInitLogic.GetJsInitStatements()
 {
     if (ConfirmationWindowContentControl != null)
     {
         this.AddJavaScriptEventScript(JsWritingMethods.onclick, confirmationWindow.GetJsOpenStatement() + " return false");
     }
     return(ActionControlStyle.GetJsInitStatements());
 }
コード例 #7
0
 string ControlWithJsInitLogic.GetJsInitStatements()
 {
     if (ConfirmationWindowContentControl != null)
     {
         this.AddJavaScriptEventScript(
             JsWritingMethods.onclick,
             "$( '#" + (confirmationWindow as EtherealControl).Control.ClientID + "' ).dialog( 'open' ); return false");
     }
     return(ActionControlStyle.GetJsInitStatements(this));
 }
コード例 #8
0
 /// <summary>
 /// Creates a link that will close the current (pop up) window and navigate in the opening window.
 /// </summary>
 /// <param name="navigatePageInfo">Where to navigate. Specify null if you don't want the link to do anything.</param>
 /// <param name="actionControlStyle">Choices are: TextActionControlStyle, ImageActionControlStyle, ButtonActionControlStyle, CustomActionControlStyle, and BoxActionControlStyle.</param>
 /// <param name="toolTipText">EWF ToolTip to display on this control. Setting ToolTipControl will ignore this property.</param>
 /// <param name="toolTipControl">Control to display inside the tool tip. Do not pass null. This will ignore the ToolTip property.</param>
 public static EwfLink CreateForNavigationInOpeningWindow(
     ResourceInfo navigatePageInfo, ActionControlStyle actionControlStyle, string toolTipText = null, Control toolTipControl = null)
 {
     return(new EwfLink(navigatePageInfo)
     {
         ActionControlStyle = actionControlStyle,
         navigatesInOpeningWindow = true,
         toolTip = toolTipText,
         toolTipControl = toolTipControl
     });
 }
コード例 #9
0
 /// <summary>
 /// Creates a link that will open a new pop up window when clicked.
 /// </summary>
 /// <param name="navigatePageInfo">Where to navigate. Specify null if you don't want the link to do anything.</param>
 /// <param name="popUpWindowSettings"></param>
 /// <param name="actionControlStyle">Choices are: TextActionControlStyle, ImageActionControlStyle, ButtonActionControlStyle, CustomActionControlStyle, and BoxActionControlStyle.</param>
 /// <param name="toolTipText">EWF ToolTip to display on this control. Setting ToolTipControl will ignore this property.</param>
 /// <param name="toolTipControl">Control to display inside the tool tip. Do not pass null. This will ignore the ToolTip property.</param>
 public static EwfLink CreateForNavigationInPopUpWindow(
     ResourceInfo navigatePageInfo, ActionControlStyle actionControlStyle, PopUpWindowSettings popUpWindowSettings, string toolTipText = null,
     Control toolTipControl = null)
 {
     return(new EwfLink(navigatePageInfo)
     {
         ActionControlStyle = actionControlStyle,
         popUpWindowSettings = popUpWindowSettings,
         toolTip = toolTipText,
         toolTipControl = toolTipControl
     });
 }
コード例 #10
0
        /// <summary>
        /// Checks that WindowToLaunch has been set and applies the attributes for this LaunchWindowLink.
        /// </summary>
        void ControlTreeDataLoader.LoadData()
        {
            if (TagKey == HtmlTextWriterTag.Button)
            {
                PostBackButton.AddButtonAttributes(this);
            }
            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            ActionControlStyle.SetUpControl(this, "");

            if (ToolTip != null || ToolTipControl != null)
            {
                new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
            }
        }
コード例 #11
0
        void ControlTreeDataLoader.LoadData()
        {
            var url = "";

            if (destinationResourceInfo != null && !(destinationResourceInfo.AlternativeMode is DisabledResourceMode))
            {
                url = destinationResourceInfo.GetUrl();
                Attributes.Add("href", this.GetClientUrl(url));
            }

            if (isPostBackButton && url.Any())
            {
                var postBack = GetLinkPostBack(destinationResourceInfo);
                EwfPage.Instance.AddPostBack(postBack);
                PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, PostBackButton.GetPostBackScript(postBack)); };
            }
            if (navigatesInNewWindow)
            {
                Attributes.Add("target", "_blank");
            }
            if (popUpWindowSettings != null && url.Any())
            {
                this.AddJavaScriptEventScript(JsWritingMethods.onclick, JsWritingMethods.GetPopUpWindowScript(url, this, popUpWindowSettings) + " return false");
            }
            if (navigatesInOpeningWindow && (destinationResourceInfo == null || url.Any()))
            {
                var openingWindowNavigationScript = destinationResourceInfo != null ? "opener.document.location = '" + this.GetClientUrl(url) + "'; " : "";
                this.AddJavaScriptEventScript(JsWritingMethods.onclick, openingWindowNavigationScript + "window.close(); return false");
            }

            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            if (destinationResourceInfo != null && destinationResourceInfo.AlternativeMode is NewContentResourceMode)
            {
                CssClass = CssClass.ConcatenateWithSpace(CssElementCreator.NewContentClass);
            }
            ActionControlStyle.SetUpControl(this, url, width, height, setWidth);

            if (destinationResourceInfo != null && destinationResourceInfo.AlternativeMode is DisabledResourceMode)
            {
                var message = (destinationResourceInfo.AlternativeMode as DisabledResourceMode).Message;
                new ToolTip(EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(message.Any() ? message : Translation.ThePageYouRequestedIsDisabled), this);
            }
            else if (toolTip != null || toolTipControl != null)
            {
                new ToolTip(toolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(toolTip), this);
            }
        }
コード例 #12
0
        /// <summary>
        /// Creates a toggle button with ControlsToToggle already populated.
        /// Use SetInitialDisplay on each control to set up the initial visibility of each control.
        /// </summary>
        public ToggleButton(
            IEnumerable <WebControl> controlsToToggle, ActionControlStyle actionControlStyle, bool controlsToggled,
            Action <PostBackValue <bool>, Validator> validationMethod, IEnumerable <string> toggleClasses = null)
        {
            AddControlsToToggle(controlsToToggle.ToArray());
            ActionControlStyle = actionControlStyle;
            this.toggleClasses = toggleClasses;

            var hiddenField = new EwfHiddenField(
                controlsToggled.ToString(),
                (postBackValue, validator) =>
                validationMethod(new PostBackValue <bool>(getControlsToggled(postBackValue.Value), postBackValue.ChangedOnPostBack), validator),
                id: hiddenFieldId,
                pageModificationValue: hiddenFieldValue);

            hiddenField.PageComponent.ToCollection().AddEtherealControls(this);
        }
コード例 #13
0
        /// <summary>
        /// Creates a post-back button.
        /// </summary>
        /// <param name="postBack">Do not pass null.</param>
        /// <param name="actionControlStyle"></param>
        /// <param name="usesSubmitBehavior">True if this button should act like a submit button (respond to the enter key). Doesn't work with the text or custom
        /// action control styles.</param>
        public PostBackButton( PostBack postBack, ActionControlStyle actionControlStyle, bool usesSubmitBehavior = true )
        {
            this.postBack = postBack;
            ActionControlStyle = actionControlStyle;
            this.usesSubmitBehavior = usesSubmitBehavior;

            EwfPage.Instance.AddControlTreeValidation(
                () => {
                    if( !this.IsOnPage() || !this.usesSubmitBehavior )
                        return;
                    var submitButtons = EwfPage.Instance.GetDescendants( EwfPage.Instance ).OfType<PostBackButton>().Where( i => i.usesSubmitBehavior ).ToArray();
                    if( submitButtons.Count() > 1 ) {
                        throw new ApplicationException(
                            "Multiple buttons with submit behavior were detected. There may only be one per page. The button IDs are " +
                            StringTools.ConcatenateWithDelimiter( ", ", submitButtons.Select( control => control.UniqueID ).ToArray() ) + "." );
                    }
                    EwfPage.Instance.SubmitButtonPostBack = this.postBack;
                } );
        }
コード例 #14
0
        void ControlTreeDataLoader.LoadData()
        {
            Attributes.Add("href",
                           "mailto:" +
                           StringTools.ConcatenateWithDelimiter("?",
                                                                ToAddress,
                                                                StringTools.ConcatenateWithDelimiter("&",
                                                                                                     CcAddress.PrependDelimiter("cc="),
                                                                                                     BccAddress.PrependDelimiter("bcc="),
                                                                                                     HttpUtility.UrlEncode(Subject).PrependDelimiter("subject="),
                                                                                                     HttpUtility.UrlEncode(Body).PrependDelimiter("body="))));

            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            ActionControlStyle.SetUpControl(this, "", width, height, setWidth);

            if (ToolTip != null || ToolTipControl != null)
            {
                new ToolTip(ToolTipControl ?? EnterpriseWebFramework.Controls.ToolTip.GetToolTipTextControl(ToolTip), this);
            }
        }
コード例 #15
0
        void ControlTreeDataLoader.LoadData()
        {
            if (toolTipControl == null)
            {
                throw new ApplicationException("ToolTipControl must be set on ToolTipLink");
            }

            if (TagKey == HtmlTextWriterTag.Button)
            {
                PostBackButton.AddButtonAttributes(this);
            }

            // NOTE: When this control is rendered as an anchor, the presence of an onclick attribute is necessary for it to be selected properly by our action
            // control CSS elements. This hack would not be necessary if Telerik used the onclick attribute to open the tool tip.
            this.AddJavaScriptEventScript(JsWritingMethods.onclick, "");

            CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
            ActionControlStyle.SetUpControl(this, "", Unit.Empty, Unit.Empty, width => { });

            new ToolTip(toolTipControl, this, title: ToolTipTitle ?? "", sticky: true);
        }
コード例 #16
0
        /// <summary>
        /// Creates a post-back button.
        /// </summary>
        /// <param name="postBack">Do not pass null.</param>
        /// <param name="actionControlStyle"></param>
        /// <param name="usesSubmitBehavior">True if this button should act like a submit button (respond to the enter key). Doesn't work with the text or custom
        /// action control styles.</param>
        public PostBackButton(PostBack postBack, ActionControlStyle actionControlStyle, bool usesSubmitBehavior = true)
        {
            this.postBack           = postBack;
            ActionControlStyle      = actionControlStyle;
            this.usesSubmitBehavior = usesSubmitBehavior;

            EwfPage.Instance.AddControlTreeValidation(
                () => {
                if (!this.IsOnPage() || !this.usesSubmitBehavior)
                {
                    return;
                }
                var submitButtons = EwfPage.Instance.GetDescendants().OfType <PostBackButton>().Where(i => i.usesSubmitBehavior).ToArray();
                if (submitButtons.Count() > 1)
                {
                    throw new ApplicationException(
                        "Multiple buttons with submit behavior were detected. There may only be one per page. The button IDs are " +
                        StringTools.ConcatenateWithDelimiter(", ", submitButtons.Select(control => control.UniqueID).ToArray()) + ".");
                }
                EwfPage.Instance.SubmitButtonPostBack = this.postBack;
            });
        }
コード例 #17
0
        /// <summary>
        /// Creates a post-back button.
        /// </summary>
        /// <param name="actionControlStyle"></param>
        /// <param name="usesSubmitBehavior">True if this button should act like a submit button (respond to the enter key). Doesn't work with the text or custom
        /// action control styles.</param>
        /// <param name="postBack">Pass null to use the post-back corresponding to the first of the current data modifications.</param>
        public PostBackButton(ActionControlStyle actionControlStyle, bool usesSubmitBehavior = true, PostBack postBack = null)
        {
            ActionControlStyle      = actionControlStyle;
            this.usesSubmitBehavior = usesSubmitBehavior;
            postBackAction          = new PostBackFormAction(postBack ?? FormState.Current.PostBack);

            EwfPage.Instance.AddControlTreeValidation(
                () => {
                if (!this.IsOnPage() || !this.usesSubmitBehavior)
                {
                    return;
                }
                var submitButtons = EwfPage.Instance.GetDescendants(EwfPage.Instance).OfType <PostBackButton>().Where(i => i.usesSubmitBehavior).ToArray();
                if (submitButtons.Length > 1)
                {
                    throw new ApplicationException(
                        "Multiple buttons with submit behavior were detected. There may only be one per page. The button IDs are " +
                        StringTools.ConcatenateWithDelimiter(", ", submitButtons.Select(control => control.UniqueID).ToArray()) + ".");
                }
                EwfPage.Instance.SubmitButtonPostBack = postBackAction.PostBack;
            });

            dataModifications = FormState.Current.DataModifications;
        }
コード例 #18
0
 string ControlWithJsInitLogic.GetJsInitStatements()
 {
     return(ActionControlStyle.GetJsInitStatements(this));
 }
コード例 #19
0
 /// <summary>
 /// Creates a link.
 /// </summary>
 /// <param name="navigatePageInfo">Where to navigate. Specify null if you don't want the link to do anything.</param>
 /// <param name="actionControlStyle">Choices are: TextActionControlStyle, ImageActionControlStyle, ButtonActionControlStyle, CustomActionControlStyle, and BoxActionControlStyle.</param>
 /// <param name="toolTipText">EWF ToolTip to display on this control. Setting ToolTipControl will ignore this property.</param>
 /// <param name="toolTipControl">Control to display inside the tool tip. Do not pass null. This will ignore the ToolTip property.</param>
 public static EwfLink Create( ResourceInfo navigatePageInfo, ActionControlStyle actionControlStyle, string toolTipText = null, Control toolTipControl = null )
 {
     return new EwfLink( navigatePageInfo ) { ActionControlStyle = actionControlStyle, toolTip = toolTipText, toolTipControl = toolTipControl };
 }
コード例 #20
0
 string ControlWithJsInitLogic.GetJsInitStatements()
 {
     this.AddJavaScriptEventScript(JsWritingMethods.onclick, windowToLaunch.GetJsOpenStatement() + " return false");
     return(ActionControlStyle.GetJsInitStatements());
 }
コード例 #21
0
 string ControlWithJsInitLogic.GetJsInitStatements()
 {
     this.AddJavaScriptEventScript(JsWritingMethods.onclick,
                                   "$( '#" + (windowToLaunch as EtherealControl).Control.ClientID + "' ).dialog( 'open' ); return false");
     return(ActionControlStyle.GetJsInitStatements(this));
 }
コード例 #22
0
 public PostBackButton(PostBack postBack, ActionControlStyle actionControlStyle, bool usesSubmitBehavior = true)
     : this(actionControlStyle, usesSubmitBehavior : usesSubmitBehavior, postBack : postBack)
 {
 }
コード例 #23
0
 /// <summary>
 /// Creates a toggle button with ControlsToToggle already populated.
 /// Use SetInitialDisplay on each control to set up the initial visibility of each control.
 /// </summary>
 public ToggleButton(IEnumerable <WebControl> controlsToToggle, ActionControlStyle actionControlStyle, IEnumerable <string> toggleClasses = null)
 {
     AddControlsToToggle(controlsToToggle.ToArray());
     ActionControlStyle = actionControlStyle;
     this.toggleClasses = toggleClasses;
 }
コード例 #24
0
 internal static HtmlTextWriterTag GetTagKey( ActionControlStyle actionControlStyle )
 {
     // NOTE: In theory, we should always return the button tag, but buttons are difficult to style in IE7.
     // NOTE: Another problem with button is that according to the HTML Standard, it can only contain phrasing content.
     return actionControlStyle is TextActionControlStyle || actionControlStyle is CustomActionControlStyle ? HtmlTextWriterTag.A : HtmlTextWriterTag.Button;
 }
コード例 #25
0
 /// <summary>
 /// Guaranteed to stay public through 28 February 2013.
 /// </summary>
 public EwfLink(ResourceInfo destinationResourceInfo)
 {
     this.destinationResourceInfo = destinationResourceInfo;
     ActionControlStyle           = new TextActionControlStyle("");
 }
コード例 #26
0
 internal static HtmlTextWriterTag GetTagKey(ActionControlStyle actionControlStyle)
 {
     // NOTE: In theory, we should always return the button tag, but buttons are difficult to style in IE7.
     // NOTE: Another problem with button is that according to the HTML Standard, it can only contain phrasing content.
     return(actionControlStyle is TextActionControlStyle || actionControlStyle is CustomActionControlStyle ? HtmlTextWriterTag.A : HtmlTextWriterTag.Button);
 }
コード例 #27
0
 /// <summary>
 /// Creates a link that will open a new pop up window when clicked.
 /// </summary>
 /// <param name="navigatePageInfo">Where to navigate. Specify null if you don't want the link to do anything.</param>
 /// <param name="popUpWindowSettings"></param>
 /// <param name="actionControlStyle">Choices are: TextActionControlStyle, ImageActionControlStyle, ButtonActionControlStyle, CustomActionControlStyle, and BoxActionControlStyle.</param>
 /// <param name="toolTipText">EWF ToolTip to display on this control. Setting ToolTipControl will ignore this property.</param>
 /// <param name="toolTipControl">Control to display inside the tool tip. Do not pass null. This will ignore the ToolTip property.</param>
 public static EwfLink CreateForNavigationInPopUpWindow(
     ResourceInfo navigatePageInfo, ActionControlStyle actionControlStyle, PopUpWindowSettings popUpWindowSettings, string toolTipText = null,
     Control toolTipControl = null)
 {
     return new EwfLink( navigatePageInfo )
         {
             ActionControlStyle = actionControlStyle,
             popUpWindowSettings = popUpWindowSettings,
             toolTip = toolTipText,
             toolTipControl = toolTipControl
         };
 }
コード例 #28
0
 /// <summary>
 /// Creates a toggle button with ControlsToToggle already populated.
 /// Use SetInitialDisplay on each control to set up the initial visibility of each control.
 /// </summary>
 public ToggleButton( IEnumerable<WebControl> controlsToToggle, ActionControlStyle actionControlStyle, IEnumerable<string> toggleClasses = null )
 {
     AddControlsToToggle( controlsToToggle.ToArray() );
     ActionControlStyle = actionControlStyle;
     this.toggleClasses = toggleClasses;
 }
コード例 #29
0
 /// <summary>
 /// Creates a link that will close the current (pop up) window and navigate in the opening window.
 /// </summary>
 /// <param name="navigatePageInfo">Where to navigate. Specify null if you don't want the link to do anything.</param>
 /// <param name="actionControlStyle">Choices are: TextActionControlStyle, ImageActionControlStyle, ButtonActionControlStyle, CustomActionControlStyle, and BoxActionControlStyle.</param>
 /// <param name="toolTipText">EWF ToolTip to display on this control. Setting ToolTipControl will ignore this property.</param>
 /// <param name="toolTipControl">Control to display inside the tool tip. Do not pass null. This will ignore the ToolTip property.</param>
 public static EwfLink CreateForNavigationInOpeningWindow(
     ResourceInfo navigatePageInfo, ActionControlStyle actionControlStyle, string toolTipText = null, Control toolTipControl = null)
 {
     return new EwfLink( navigatePageInfo )
         {
             ActionControlStyle = actionControlStyle,
             navigatesInOpeningWindow = true,
             toolTip = toolTipText,
             toolTipControl = toolTipControl
         };
 }