/// <summary> /// 将属性添加到控件中 /// </summary> /// <param name="accessor"></param> /// <param name="attributeName"></param> /// <param name="attributeValue"></param> public static void AddAttribute(IAttributeAccessor accessor, string attributeName, string attributeValue) { if (accessor != null && attributeName != null) { accessor.SetAttribute(attributeName, attributeValue); } }
private void InitTargetControl(IAttributeAccessor target) { if (target != null) { target.SetAttribute("onclick", string.Format("event.returnValue = false; if (!this.disabled) $find(\"{0}\")._doOperation();return false;", this.ClientID)); target.SetAttribute("class", "enable"); if (this.Visible) { if (NeedToRender == false) { target.SetAttribute("disabled", "true"); target.SetAttribute("class", "disable"); } if (target is IButtonControl) { IButtonControl button = (IButtonControl)target; string buttonText = "退件"; if (WfClientContext.Current.CurrentActivity != null) { buttonText = WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("ReturnButtonName", "退件"); } button.Text = button.Text.Replace("退件", HttpUtility.HtmlEncode(buttonText)); } } else { ((Control)target).Visible = false; } } }
private void SetCssAttribute(IAttributeAccessor aa, string cssName) { if (string.IsNullOrEmpty(aa.GetAttribute("class"))) { aa.SetAttribute("class", cssName); } }
/// <summary> /// Registers the static control. /// </summary> /// <param name="control">The control.</param> /// <param name="wrapper">The wrapper.</param> /// <param name="controlUid">The control uid.</param> public static void RegisterStaticControl(Control control, IAttributeAccessor wrapper, string controlUid) { if (!IsDynamicControl(control)) { ControlSettings cs = PageDocument.Current.StaticNode.Controls[control.ID]; if (cs == null) { cs = new ControlSettings(); PageDocument.Current.StaticNode.Controls.Add(control.ID, cs); } else { if (control is ICmsDataAdapter) { ControlSettings settings = PageDocument.Current.StaticNode.Controls[control.ID]; ((ICmsDataAdapter)control).SetParamInfo(settings); } } // Since it is a static control, add a properties dialog if (CMSContext.Current.IsDesignMode && wrapper != null) { string controlId = controlUid; string command = CmsPlaceHolder.CreatePropertiesCommand(control.ID, controlId); if (!String.IsNullOrEmpty(command)) { wrapper.SetAttribute("ondblclick", command); } } } }
private static void InitTraceControlEntry(IAttributeAccessor target, string resourceID, string processID) { target.SetAttribute("resourceID", resourceID); target.SetAttribute("feature", GetWindowFeature().ToWindowFeatureClientString()); ResourceUriSettings settings = ResourceUriSettings.GetConfig(); string path = "/MCSWebApp/OACommonPages/AppTrace/appTraceViewer.aspx"; if (settings.Paths.ContainsKey("appTrace")) { path = settings.Paths["appTrace"].Uri.ToString(); } target.SetAttribute("href", string.Format(path + "?resourceID={0}&processID={1}&{2}={3}", resourceID, processID, GlobalizationWebHelper.LanguageParameterName, HttpUtility.UrlEncode(GlobalizationWebHelper.GetCurrentHandlerLanguageID()))); target.SetAttribute("target", "WfTrace" + resourceID.Replace("-", string.Empty)); target.SetAttribute("onclick", "onWfTraceButtonClick()"); }
private void InitScript() { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SignInScriptOnload", Resource.changePasswordScript, true); Page.ClientScript.RegisterStartupScript(this.GetType(), "ChangePasswordScriptOnload", string.Format("window.attachEvent(\"onload\", new Function(\"initControlsFocus('{0}', '{1}')\"));", PassportWebControlHelper.GetControlValue(this.TemplateControl, "signInName", "ClientID", string.Empty), PassportWebControlHelper.GetControlValue(this.TemplateControl, "oldPassword", "ClientID", string.Empty)), true); Control detailErrorMessageLink = PassportWebControlHelper.FindControlRecursively(this.TemplateControl, "detailErrorMessageLink"); if (detailErrorMessageLink != null && detailErrorMessageLink is HtmlContainerControl) { ((HtmlContainerControl)detailErrorMessageLink).Attributes["onclick"] = string.Format("doDetailErrorMessageClick(\"{0}\")", PassportWebControlHelper.GetControlValue(this.TemplateControl, "detailErrorMessage", "ClientID", string.Empty)); } this.updateButton.OnClientClick = string.Format("beforeSubmit(\"{0}\", \"{1}\", \"{2}\", \"{3}\")", PassportWebControlHelper.GetControlValue(this.TemplateControl, "signInName", "ClientID", string.Empty), PassportWebControlHelper.GetControlValue(this.TemplateControl, "errorMessage", "ClientID", string.Empty), PassportWebControlHelper.GetControlValue(this.TemplateControl, "newPassword", "ClientID", string.Empty), PassportWebControlHelper.GetControlValue(this.TemplateControl, "confirmPassword", "ClientID", string.Empty)); IAttributeAccessor backButton = (IAttributeAccessor)PassportWebControlHelper.FindControlRecursively(this.TemplateControl, "backButton"); if (backButton != null) { backButton.SetAttribute("backUrl", this.GetBackUrl()); backButton.SetAttribute("onclick", "onBackButtonClick();"); } }
public void Attributes() { HtmlForm form = new HtmlForm(); IAttributeAccessor a = (IAttributeAccessor)form; /* not stored in Attributes */ form.DefaultButton = "defaultbutton"; Assert.IsNull(a.GetAttribute("defaultbutton"), "A1"); /* not stored in Attributes */ form.DefaultFocus = "defaultfocus"; Assert.IsNull(a.GetAttribute("defaultfocus"), "A2"); form.Enctype = "enctype"; Assert.AreEqual("enctype", a.GetAttribute("enctype"), "A3"); form.Method = "method"; Assert.AreEqual("method", a.GetAttribute("method"), "A4"); /* not stored in Attributes */ form.Name = "name"; Assert.AreEqual(form.UniqueID, form.Name, "A5"); Assert.IsNull(form.Name, "A6"); Assert.IsNull(form.UniqueID, "A7"); Assert.IsNull(a.GetAttribute("name"), "A8"); form.ID = "hithere"; Assert.AreEqual("hithere", form.Name, "A9"); form.SubmitDisabledControls = true; Assert.IsNull(a.GetAttribute("submitdisabledcontrols"), "A10"); form.Target = "target"; Assert.AreEqual("target", a.GetAttribute("target"), "A11"); }
private void CopyChildAttributes() { // Copy the attribute values from the ChildControl to the GenericWebPart properties. IAttributeAccessor childAttributeAccessor = ChildControl as IAttributeAccessor; if (childAttributeAccessor != null) { base.AuthorizationFilter = childAttributeAccessor.GetAttribute("AuthorizationFilter"); base.CatalogIconImageUrl = childAttributeAccessor.GetAttribute("CatalogIconImageUrl"); base.Description = childAttributeAccessor.GetAttribute("Description"); string exportMode = childAttributeAccessor.GetAttribute("ExportMode"); if (exportMode != null) { base.ExportMode = (WebPartExportMode)(Util.GetEnumAttribute( "ExportMode", exportMode, typeof(WebPartExportMode))); } // Don't need to check base.Subtitle, since we always want to use the Subtitle on the // ChildControl if it is present. Also, the property is not settable on WebPart, so we // know that base.Subtitle will always be String.Empty. _subtitle = childAttributeAccessor.GetAttribute("Subtitle"); base.Title = childAttributeAccessor.GetAttribute("Title"); base.TitleIconImageUrl = childAttributeAccessor.GetAttribute("TitleIconImageUrl"); base.TitleUrl = childAttributeAccessor.GetAttribute("TitleUrl"); } // Remove all the attributes from the ChildControl, whether or not they were copied // to the GenericWebPart property. We want to remove the attributes so they are not // rendered on the ChildControl. (VSWhidbey 313674) WebControl childWebControl = ChildControl as WebControl; if (childWebControl != null) { // If the ChildControl is a WebControl, we want to completely remove the attributes. childWebControl.Attributes.Remove("AuthorizationFilter"); childWebControl.Attributes.Remove("CatalogIconImageUrl"); childWebControl.Attributes.Remove("Description"); childWebControl.Attributes.Remove("ExportMode"); childWebControl.Attributes.Remove("Subtitle"); childWebControl.Attributes.Remove("Title"); childWebControl.Attributes.Remove("TitleIconImageUrl"); childWebControl.Attributes.Remove("TitleUrl"); } else if (childAttributeAccessor != null) { // If the ChildControl is not a WebControl, we cannot remove the attributes, so we set // them to null instead. childAttributeAccessor.SetAttribute("AuthorizationFilter", null); childAttributeAccessor.SetAttribute("CatalogIconImageUrl", null); childAttributeAccessor.SetAttribute("Description", null); childAttributeAccessor.SetAttribute("ExportMode", null); childAttributeAccessor.SetAttribute("Subtitle", null); childAttributeAccessor.SetAttribute("Title", null); childAttributeAccessor.SetAttribute("TitleIconImageUrl", null); childAttributeAccessor.SetAttribute("TitleUrl", null); } }
protected virtual Exception PayloadWhenNull(IAttributeAccessor context) { var message = (IMessage)context.GetAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY); return(message == null ? new MessagingException("No root cause exception available") : new MessagingException(message, "No root cause exception available")); }
/** * Copy the attributes from the supplied AttributeAccessor to this accessor. * @param source the AttributeAccessor to copy from */ protected void CopyAttributesFrom(IAttributeAccessor source) { Trace.Assert(source != null, "Source must not be null"); string[] attributeNames = source.AttributeNames; foreach(string attributeName in attributeNames) { SetAttribute(attributeName, source.GetAttribute(attributeName)); } }
public virtual void Publish(Exception exception, IAttributeAccessor context) { PopulateChannel(); var payload = DeterminePayload(exception, context); var errorMessage = _errorMessageStrategy.BuildErrorMessage(payload, context); _messagingTemplate.Send(errorMessage); }
public bool ApplyAuth(Control control) { if (control is IAttributeAccessor) { IAttributeAccessor attributeAccessor = (IAttributeAccessor)control; return(string.IsNullOrWhiteSpace(attributeAccessor.GetAttribute("data-auth"))); } return(false); }
private void InitProcessControl(IAttributeAccessor target) { if (target != null) { target.SetAttribute("onclick", string.Format("if (!event.srcElement.disabled) $find('{0}').doInternalOperation(); return false;", this.ClientID)); SetTargetControlVisible((Control)target); } }
/// <summary> /// Initializes a new instance of the <see cref="SchemaFactory"/> class. /// </summary> /// <param name="attributeAccessor">The attribute accessor.</param> /// <param name="graphTypeProvider">The graph type provider.</param> /// <param name="binderProvider">The binder provider.</param> public SchemaFactory( IAttributeAccessor attributeAccessor, IGraphTypeProvider graphTypeProvider, IArgumentBinderProvider binderProvider) { _attributeAccessor = attributeAccessor ?? throw new ArgumentNullException(nameof(attributeAccessor)); _graphTypeProvider = graphTypeProvider ?? throw new ArgumentNullException(nameof(graphTypeProvider)); _binderProvider = binderProvider ?? throw new ArgumentNullException(nameof(binderProvider)); }
public ErrorMessage BuildErrorMessage(Exception exception, IAttributeAccessor attributes) { var inputMessage = attributes?.GetAttribute(ErrorMessageUtils.INPUT_MESSAGE_CONTEXT_KEY); return(inputMessage switch { IMessage iMessage => new ErrorMessage(exception, iMessage), _ => new ErrorMessage(exception) });
/** * Copy the attributes from the supplied AttributeAccessor to this accessor. * @param source the AttributeAccessor to copy from */ protected void CopyAttributesFrom(IAttributeAccessor source) { Trace.Assert(source != null, "Source must not be null"); string[] attributeNames = source.AttributeNames; foreach (string attributeName in attributeNames) { SetAttribute(attributeName, source.GetAttribute(attributeName)); } }
/// <summary> /// 将属性添加到控件中 /// </summary> /// <param name="accessor">控件</param> /// <param name="attributes">属性集合</param> public static void AddAttributes(IAttributeAccessor accessor, StringDictionary attributes) { if (accessor != null && attributes != null) { foreach (string key in attributes.Keys) { accessor.SetAttribute(key, attributes[key]); } } }
private void ApplyBoundProperties(Control control) { DataBindingCollection dataBindings = null; IAttributeAccessor attributeAccessor = null; foreach (BoundPropertyEntry entry in base.GetFilteredPropertyEntrySet(this._skinBuilder.BoundPropertyEntries)) { this.InitBoundProperty(control, entry, ref dataBindings, ref attributeAccessor); } }
/// <summary> /// Initializes a new instance of the <see cref="GraphTypeProvider" /> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="attributeAccessor">The attribute accessor.</param> /// <param name="optionsAccessor">The options accessor.</param> public GraphTypeProvider(IServiceProvider serviceProvider, IAttributeAccessor attributeAccessor, IOptions <GraphOptions> optionsAccessor) { _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _attributeAccessor = attributeAccessor ?? throw new ArgumentNullException(nameof(attributeAccessor)); _graphTypes = new Dictionary <string, IGraphType>(); _fieldNameConverter = Guard.ArgumentNotNull(optionsAccessor, nameof(optionsAccessor)).Value.FieldNameConverter; foreach (var scalarType in GraphValueResolver.ScalarTypes) { GetGraphType(scalarType, null, false); } }
// This has become pure decoration. I still think it's nice to have for developmental purposes/reference. public void SetWidgetNameOnTarget(IAttributeAccessor targetControl) { String attr = targetControl.GetAttribute("data-ui-widget") ?? String.Empty; if (!attr.Contains(Widget.WidgetName)) { attr = String.IsNullOrEmpty(attr) ? Widget.WidgetName : String.Join(",", attr, Widget.WidgetName); targetControl.SetAttribute("data-ui-widget", attr); } }
/// <summary> /// 向一个控件添加一个确认对话框.(如果取消则不提交服务器端) /// </summary> /// <param name="c">需要添加确认的控件</param> /// <param name="msg">对话框中显示的文本</param> public static void AddConfirmToControl(IAttributeAccessor c, string msg) { if (c is HtmlControl) { ((HtmlControl)c).Attributes.Add("onclick", "return confirm('" + msg + "');"); } else if (c is WebControl) { ((WebControl)c).Attributes.Add("onclick", "return confirm('" + msg + "');"); } }
/// <summary> /// 如果此控件不存在此属性,将属性添加到控件中 /// </summary> /// <param name="accessor"></param> /// <param name="attributeName"></param> /// <param name="attributeValue"></param> public static void AddAttributeIfNotExists(IAttributeAccessor accessor, string attributeName, string attributeValue) { if (accessor == null || attributeName == null) { return; } if (accessor.GetAttribute(attributeName) == null) { accessor.SetAttribute(attributeName, attributeValue); } }
/// <summary> /// 将属性添加到控件中 /// </summary> /// <param name="accessor">控件</param> /// <param name="attributes">属性集合</param> public static void AddAttributes(IAttributeAccessor accessor, StringDictionary attributes) { if (accessor == null || attributes == null) { return; } foreach (string key in attributes.Keys) { accessor.SetAttribute(key, attributes[key]); } }
private void ApplyChangesToRuntimeChoice_helper( PropertyDescriptor property, Object sourceTarget, Object destTarget, String prefix ) { Object oldValue = property.GetValue(sourceTarget); Object newValue = property.GetValue(destTarget); String propertyName = prefix + property.Name; if (property.Converter is ExpandableObjectConverter) { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties( newValue.GetType() ); foreach (PropertyDescriptor embeddedProperty in properties) { if (IsDeviceOverridable(embeddedProperty)) { ApplyChangesToRuntimeChoice_helper( embeddedProperty, oldValue, newValue, propertyName + "-" ); } } } else if (IsDeviceOverridable(property)) { IAttributeAccessor overrides = (IAttributeAccessor)_choice; String oldValueString = property.Converter.ConvertToInvariantString( oldValue ); String newValueString = property.Converter.ConvertToInvariantString( newValue ); if (newValueString != oldValueString) { overrides.SetAttribute(propertyName, newValueString); } else { // Clear any previous values we might have loaded overrides.SetAttribute(propertyName, null); } } }
protected List <SDK.Operation> GetSDKOperationListFromControl(Control control) { List <SDK.Operation> sdkOpearationList = new List <SDK.Operation>(); if (control is IAttributeAccessor) { IAttributeAccessor attributeAccessor = (IAttributeAccessor)control; var list = this.Serializer.Deserialize <List <SDK.Operation> >(attributeAccessor.GetAttribute("data-auth") ?? "[]"); sdkOpearationList.AddRange(list); } return(CalculateSDKOperationList(sdkOpearationList)); }
protected override Exception PayloadWhenNull(IAttributeAccessor context) { var message = (IMessage)context.GetAttribute(ErrorMessageUtils.FAILED_MESSAGE_CONTEXT_KEY); var description = "No retry exception available; " + "this can occur, for example, if the RetryPolicy allowed zero attempts " + "to execute the handler; " + "RetryContext: " + context.ToString(); return(message == null ? new RetryExceptionNotAvailableException(description) : new RetryExceptionNotAvailableException(message, description)); }
private void ApplyBoundProperties(Control control) { DataBindingCollection dataBindings = null; IAttributeAccessor attributeAccessor = null; // If there are no filters in the picture, use the entries as is ICollection entries = GetFilteredPropertyEntrySet(_skinBuilder.BoundPropertyEntries); foreach (BoundPropertyEntry entry in entries) { InitBoundProperty(control, entry, ref dataBindings, ref attributeAccessor); } }
private static bool CategoryDefined(Control control) { bool result = false; if (control is IAttributeAccessor) { IAttributeAccessor accessor = (IAttributeAccessor)control; result = string.IsNullOrEmpty(accessor.GetAttribute("Category")) == false; } return(result); }
public ErrorMessage BuildErrorMessage(Exception exception, IAttributeAccessor attributes) { var inputMessage = attributes == null ? null : attributes.GetAttribute(ErrorMessageUtils.INPUT_MESSAGE_CONTEXT_KEY); if (inputMessage is IMessage) { return(new ErrorMessage(exception, (IMessage)inputMessage)); } else { return(new ErrorMessage(exception)); } }
private void InitTargetControl(IAttributeAccessor target) { if (target != null) { target.SetAttribute("onclick", string.Format("event.returnValue = false; if (!this.disabled) $find(\"{0}\")._doOperation();return false;", this.ClientID)); target.SetAttribute("class", "enable"); if (NeedToRender == false) { //target.SetAttribute("disabled", "true"); target.SetAttribute("class", "invisible"); } } }
protected virtual void CopyAttributesFrom(IAttributeAccessor source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } var attributeNames = source.AttributeNames; foreach (var attributeName in attributeNames) { SetAttribute(attributeName, source.GetAttribute(attributeName)); } }
protected override void OnInit(EventArgs e) { Control targetControl = FindControl(_targetId); _propInfo = targetControl.GetType().GetProperty(_attributeName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); if (_propInfo == null) { // Couldn't find a real property. Try IAttributeAccessor _attributeAccessor = targetControl as IAttributeAccessor; if (_attributeAccessor == null) { Misc.ThrowException("Control '" + _targetId + "' doesn't have a property named '" + _attributeName + "'", null, TemplateControl.AppRelativeVirtualPath, Line); } } targetControl.DataBinding += new EventHandler(ControlOnDataBinding); }
/// <summary> /// 设置实现了IAttributeAccessor接口的控件的Attribute(保留原来同Key的Attribute) /// </summary> /// <param name="iaa">实现了IAttributeAccessor接口的控件</param> /// <param name="key">属性的名称</param> /// <param name="value">属性的值</param> /// <param name="csp">属性的值的位置</param> /// <param name="separator">属性分隔符</param> public static void SetAttribute(IAttributeAccessor iaa, string key, string value, AttributeValuePosition csp, char separator) { string tmp = iaa.GetAttribute(key); if (String.IsNullOrEmpty(tmp)) { iaa.SetAttribute(key, value); } else if (csp == AttributeValuePosition.First) { tmp = tmp.TrimStart(separator); iaa.SetAttribute(key, value + separator + tmp); } else if (csp == AttributeValuePosition.Last) { tmp = tmp.TrimEnd(separator); iaa.SetAttribute(key, tmp + separator + value); } }
private void InitTargetControl(IAttributeAccessor target) { if (NeedToRender == false) { target.SetAttribute("disabled", "true"); target.SetAttribute("class", "disable"); target.SetAttribute("style", "display:none"); } else { target.SetAttribute("href", "#"); target.SetAttribute("class", "enable"); } }
public void SetWidgetNameOnTarget(IAttributeAccessor targetControl) { targetControl.SetAttribute("data-ui-widget", Widget.WidgetName); }
private void InitBoundProperty(Control control, BoundPropertyEntry entry, ref DataBindingCollection dataBindings, ref IAttributeAccessor attributeAccessor) { if (entry.ExpressionPrefix.Length != 0) { throw new InvalidOperationException(System.Web.SR.GetString("ControlBuilder_ExpressionsNotAllowedInThemes")); } if ((dataBindings == null) && (control != null)) { dataBindings = ((IDataBindingsAccessor) control).DataBindings; } dataBindings.Add(new DataBinding(entry.Name, entry.Type, entry.Expression.Trim())); }
/// <summary> /// 设置实现了IAttributeAccessor接口的控件的Attribute(保留原来同Key的Attribute) /// </summary> /// <param name="iaa">实现了IAttributeAccessor接口的控件</param> /// <param name="key">属性的名称</param> /// <param name="value">属性的值</param> /// <param name="csp">属性的值的位置</param> public static void SetAttribute(IAttributeAccessor iaa, string key, string value, AttributeValuePosition csp) { SetAttribute(iaa, key, value, csp, ';'); }
private void InitCopyFormTargetControl(IAttributeAccessor target) { string resourceID = WfClientContext.Current.OriginalActivity.Process.ResourceID; string processDescKey = WfClientContext.Current.OriginalActivity.RootActivity.Descriptor.Process.Key; string appName = WfClientContext.Current.OriginalActivity.Process.Descriptor.ApplicationName; string programName = WfClientContext.Current.OriginalActivity.Process.Descriptor.ProgramName; target.SetAttribute("resourceID", resourceID); target.SetAttribute("feature", GetWindowFeature().ToWindowFeatureClientString()); ResourceUriSettings settings = ResourceUriSettings.GetConfig(); string path = WfClientContext.Current.EntryUri.ToString(); target.SetAttribute("href", string.Format(path + "?processDescKey={0}&sourceResourceID={1}&appName={2}&programName={3}", HttpUtility.UrlEncode(processDescKey), HttpUtility.UrlEncode(resourceID), HttpUtility.UrlEncode(appName), HttpUtility.UrlEncode(programName))); target.SetAttribute("target", "_blank" + resourceID.Replace("-", string.Empty)); target.SetAttribute("onclick", "onOpenFormButtonClick();top.$HBRootNS.WfProcessControlBase.close();"); }
private void InitTargetControl(IAttributeAccessor target) { if (NeedToRender == false) { target.SetAttribute("disabled", "true"); target.SetAttribute("class", "disable"); target.SetAttribute("onclick", "return false;"); } else { InitCopyFormTargetControl(target); target.SetAttribute("class", "enable"); } }
private void InitBoundProperty(object obj, BoundPropertyEntry entry, ref DataBindingCollection dataBindings, ref IAttributeAccessor attributeAccessor) { string str = (entry.ExpressionPrefix == null) ? string.Empty : entry.ExpressionPrefix.Trim(); if (this.InDesigner) { if (string.IsNullOrEmpty(str)) { if ((dataBindings == null) && (obj is IDataBindingsAccessor)) { dataBindings = ((IDataBindingsAccessor) obj).DataBindings; } dataBindings.Add(new DataBinding(entry.Name, entry.Type, entry.Expression.Trim())); } else if (obj is IExpressionsAccessor) { string expression = (entry.Expression == null) ? string.Empty : entry.Expression.Trim(); ((IExpressionsAccessor) obj).Expressions.Add(new ExpressionBinding(entry.Name, entry.Type, str, expression, entry.Generated, entry.ParsedExpressionData)); } } else { if (!string.IsNullOrEmpty(str)) { ExpressionBuilderContext context; ExpressionBuilder expressionBuilder = entry.ExpressionBuilder; if (!expressionBuilder.SupportsEvaluate) { return; } string name = entry.Name; if (this.TemplateControl != null) { context = new ExpressionBuilderContext(this.TemplateControl); } else { context = new ExpressionBuilderContext(this.VirtualPath); } object obj2 = expressionBuilder.EvaluateExpression(obj, entry, entry.ParsedExpressionData, context); if (entry.UseSetAttribute) { if (attributeAccessor == null) { attributeAccessor = (IAttributeAccessor) obj; } attributeAccessor.SetAttribute(name, obj2.ToString()); return; } try { PropertyMapper.SetMappedPropertyValue(obj, name, obj2, this.InDesigner); return; } catch (Exception exception) { throw new HttpException(System.Web.SR.GetString("Cannot_set_property", new object[] { entry.ExpressionPrefix + ":" + entry.Expression, name }), exception); } } ((Control) obj).DataBinding += new EventHandler(this.DataBindingMethod); } }
private void SetCssAttribute(IAttributeAccessor aa, string cssName) { if (string.IsNullOrEmpty(aa.GetAttribute("class"))) aa.SetAttribute("class", cssName); }
private static void InitTraceControlEntry(IAttributeAccessor target, string resourceID, string processID) { target.SetAttribute("resourceID", resourceID); target.SetAttribute("feature", GetWindowFeature().ToWindowFeatureClientString()); ResourceUriSettings settings = ResourceUriSettings.GetConfig(); string path = "/MCSWebApp/OACommonPages/AppTrace/appTraceViewer.aspx"; if (settings.Paths.ContainsKey("appTrace")) path = settings.Paths["appTrace"].Uri.ToString(); target.SetAttribute("href", string.Format(path + "?resourceID={0}&processID={1}&{2}={3}", resourceID, processID, GlobalizationWebHelper.LanguageParameterName, HttpUtility.UrlEncode(GlobalizationWebHelper.GetCurrentHandlerLanguageID()))); target.SetAttribute("target", "WfTrace" + resourceID.Replace("-", string.Empty)); target.SetAttribute("onclick", "onWfTraceButtonClick()"); }
private void InitBoundProperty(Control control, BoundPropertyEntry entry, ref DataBindingCollection dataBindings, ref IAttributeAccessor attributeAccessor) { string expressionPrefix = entry.ExpressionPrefix; // If we're in the designer, add the bound properties to the collections if (expressionPrefix.Length == 0) { if (dataBindings == null && control is IDataBindingsAccessor) { dataBindings = ((IDataBindingsAccessor)control).DataBindings; } dataBindings.Add(new DataBinding(entry.Name, entry.Type, entry.Expression.Trim())); } else { throw new InvalidOperationException(SR.GetString(SR.ControlBuilder_ExpressionsNotAllowedInThemes)); } }
private void InitBoundProperty(object obj, BoundPropertyEntry entry, ref DataBindingCollection dataBindings, ref IAttributeAccessor attributeAccessor) { string expressionPrefix = entry.ExpressionPrefix == null ? String.Empty : entry.ExpressionPrefix.Trim(); // If we're in the designer, add the bound properties to the collections if (InDesigner) { if (String.IsNullOrEmpty(expressionPrefix)) { if (dataBindings == null && obj is IDataBindingsAccessor) { dataBindings = ((IDataBindingsAccessor)obj).DataBindings; } dataBindings.Add(new DataBinding(entry.Name, entry.Type, entry.Expression.Trim())); } else { if (obj is IExpressionsAccessor) { string expression = entry.Expression == null ? String.Empty : entry.Expression.Trim(); ((IExpressionsAccessor)obj).Expressions.Add(new ExpressionBinding(entry.Name, entry.Type, expressionPrefix, expression, entry.Generated, entry.ParsedExpressionData)); } } } // If we're in no-compile mode, set the values for expressions that support evaluate else { if (!String.IsNullOrEmpty(expressionPrefix)) { ExpressionBuilder eb = entry.ExpressionBuilder; Debug.Assert(eb != null, "Did not expect null expression builder"); if (eb.SupportsEvaluate) { string name = entry.Name; // DevDiv Bugs 160497: Create the expression context with whatever information we have. // We used to always use the TemplateControl one, but sometimes it's null, so we should // fall back to the VirtualPath one if we can. ExpressionBuilderContext expressionContext; if (TemplateControl != null) { expressionContext = new ExpressionBuilderContext(TemplateControl); } else { expressionContext = new ExpressionBuilderContext(VirtualPath); } object value = eb.EvaluateExpression(obj, entry, entry.ParsedExpressionData, expressionContext); if (entry.UseSetAttribute) { if (attributeAccessor == null) { Debug.Assert(obj is IAttributeAccessor); attributeAccessor = (IAttributeAccessor)obj; } attributeAccessor.SetAttribute(name, value.ToString()); } else { try { PropertyMapper.SetMappedPropertyValue(obj, name, value, InDesigner); } catch (Exception e) { throw new HttpException(SR.GetString(SR.Cannot_set_property, entry.ExpressionPrefix + ":" + entry.Expression, name), e); } } } else { Debug.Fail("Got a ExpressionBuilder that does not support Evaluate in a non-compiled page"); } } else { // no-compile Bind property handling ((Control)obj).DataBinding += new EventHandler(DataBindingMethod); } } }
private void InitInnerControlAttributes(IAttributeAccessor target, Button innerBtn, string script, bool visible, bool changeText) { if (target != null) { string clickScript = string.Format("event.returnValue = false; {0}return false;", string.IsNullOrEmpty(script) ? string.Empty : script + " "); target.SetAttribute("onclick", clickScript); ((Control)target).Visible = visible; target.SetAttribute("class", "enable"); if (changeText) { WfControlNextStep step = null; if (NextSteps.Count > 0) step = NextSteps[0]; if (step != null) { if (WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("MoveToButtonNameSameAsTransitionName", false)) { if (step.TransitionDescriptor != null) { string btnName = step.TransitionDescriptor.Name; if (string.IsNullOrEmpty(btnName)) btnName = step.TransitionDescriptor.Description; if (btnName.IsNotEmpty()) { string originalText = ((IButtonControl)target).Text; ((IButtonControl)target).Text = originalText.Replace("送签", HttpUtility.HtmlEncode(btnName)); } } } } } } }
private void InitTargetControl(IAttributeAccessor target) { if (target != null) { target.SetAttribute("onclick", string.Format("event.returnValue = false; if (!this.disabled) $find(\"{0}\")._doOperation();return false;", this.ClientID)); target.SetAttribute("class", "enable"); if (this.Visible) { if (NeedToRender == false) { target.SetAttribute("disabled", "true"); target.SetAttribute("class", "disable"); } if (target is IButtonControl) { IButtonControl button = (IButtonControl)target; string buttonText = "退件"; if (WfClientContext.Current.CurrentActivity != null) buttonText = WfClientContext.Current.CurrentActivity.Descriptor.Properties.GetValue("ReturnButtonName", "退件"); button.Text = button.Text.Replace("退件", HttpUtility.HtmlEncode(buttonText)); } } else { ((Control)target).Visible = false; } } }
public static void RegisterCloseControl(IAttributeAccessor control, UpdatePanel updatepanel) { control.SetAttribute("uppHide", "true"); control.SetAttribute("uppTarget", updatepanel.ClientID); }
// This has become pure decoration. I still think it's nice to have for developmental purposes/reference. public void SetWidgetNameOnTarget(IAttributeAccessor targetControl) { String attr = targetControl.GetAttribute("data-ui-widget") ?? String.Empty; if(!attr.Contains(Widget.WidgetName)) { attr = String.IsNullOrEmpty(attr) ? Widget.WidgetName : String.Join(",", attr, Widget.WidgetName); targetControl.SetAttribute("data-ui-widget", attr); } }
private void SetOnClick(IAttributeAccessor ctrl, string value) { if (ctrl == null) return; ctrl.SetAttribute("onclick", value); }