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); }
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, ""); }); }
/// <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 }); }
/// <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()); }; }
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); }
string ControlWithJsInitLogic.GetJsInitStatements() { if (ConfirmationWindowContentControl != null) { this.AddJavaScriptEventScript(JsWritingMethods.onclick, confirmationWindow.GetJsOpenStatement() + " return false"); } return(ActionControlStyle.GetJsInitStatements()); }
string ControlWithJsInitLogic.GetJsInitStatements() { if (ConfirmationWindowContentControl != null) { this.AddJavaScriptEventScript( JsWritingMethods.onclick, "$( '#" + (confirmationWindow as EtherealControl).Control.ClientID + "' ).dialog( 'open' ); return false"); } return(ActionControlStyle.GetJsInitStatements(this)); }
/// <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 }); }
/// <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 }); }
/// <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); } }
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); } }
/// <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); }
/// <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; } ); }
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); } }
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); }
/// <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; }); }
/// <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; }
string ControlWithJsInitLogic.GetJsInitStatements() { return(ActionControlStyle.GetJsInitStatements(this)); }
/// <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 }; }
string ControlWithJsInitLogic.GetJsInitStatements() { this.AddJavaScriptEventScript(JsWritingMethods.onclick, windowToLaunch.GetJsOpenStatement() + " return false"); return(ActionControlStyle.GetJsInitStatements()); }
string ControlWithJsInitLogic.GetJsInitStatements() { this.AddJavaScriptEventScript(JsWritingMethods.onclick, "$( '#" + (windowToLaunch as EtherealControl).Control.ClientID + "' ).dialog( 'open' ); return false"); return(ActionControlStyle.GetJsInitStatements(this)); }
public PostBackButton(PostBack postBack, ActionControlStyle actionControlStyle, bool usesSubmitBehavior = true) : this(actionControlStyle, usesSubmitBehavior : usesSubmitBehavior, postBack : postBack) { }
/// <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; }
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; }
/// <summary> /// Guaranteed to stay public through 28 February 2013. /// </summary> public EwfLink(ResourceInfo destinationResourceInfo) { this.destinationResourceInfo = destinationResourceInfo; ActionControlStyle = new TextActionControlStyle(""); }
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); }
/// <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 }; }
/// <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; }
/// <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 }; }