custom-attributes

Aurelia Custom Attribute with setAttribute method()

六眼飞鱼酱① 提交于 2019-12-20 02:59:11
问题 It seems Aurelia is not aware when I create and append an element in javascript and set a custom attribute (unless I am doing something wrong). For example, const e = document.createElement('div'); e.setAttribute('custom-attr', 'some value'); body.appendChild(e); Is there a way to make Aurelia aware of this custom attribute when it gets appended? A little background: I am creating an app where the user can select their element type (e.g. input, select, checkbox etc.) and drag it around (the

Setting ASP.NET Button attributes client side and read attribute value server side

こ雲淡風輕ζ 提交于 2019-12-19 19:53:25
问题 How can I retrieve a Button custom attribute after the attribute value has been changed using javascript? Example: Asp file <asp:Button ID="Button1" runat="server" Text="Button1" /> <asp:Button ID="Button2" runat="server" Text="Button2" OnClick="Button2_Click" /> <script type="text/javascript"> var btn1 = '#<% Button1.ClientID %>'; var btn2 = '#<% Button2.ClientID %>'; $(btn1).click(function(e) { e.preventDefault(); $(btn2).attr("actIndex", "2"); }); </script> CodeBehind file protected void

Can the HttpContext be accessed within a ValidationAttribute in ASP.NET MVC?

旧街凉风 提交于 2019-12-19 06:19:08
问题 Can the HttpContext be accessed within a ValidationAttribute in ASP.NET MVC 3? I need to test for something in my route data for a match in order to return true on my validator. Thanks 回答1: Yes, you can access the static HttpContext.Current property to get the current http context. This property may return null depending on what thread you are running your validation on, or in a non http request such as in a unit test. You will most likely want to abstract away the call you make to .Current

Overwrite customattribute on derived class

北战南征 提交于 2019-12-19 05:16:22
问题 We have a custom attribute [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] public class CustomDesignerAttribute: Attribute then we have a base class decorated with this attribute [CustomDesigner(someKey, someValue)] public class BaseClass then we have a class derived from this one, decorated with same attribute (with same key, different value) [CustomDesigner(someKey, someOtherValue)] public class ChildClass : BaseClass Is there possibility that ChildClass don't create a

Adding name attribute to `User` in Devise

核能气质少年 提交于 2019-12-18 14:08:29
问题 I'm trying to add a name attribute to the User model provided by Devise. I added a "name" column to my database, and changed the sign up view so that it asks for the user's name: <h2>Sign up</h2> <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= devise_error_messages! %> <p><%= f.label :name %><br /> <%= f.text_field :name %></p> <p><%= f.label :email %><br /> <%= f.email_field :email %></p> <p><%= f.label :password %><br /> <%= f.password

What AttributeTarget should I use for enum members?

安稳与你 提交于 2019-12-18 13:52:49
问题 I want to use my IsGPUBasedAttribute for enum members like this: public enum EffectType { [IsGPUBased(true)] PixelShader, [IsGPUBased(false)] Blur } but the compiler doesn't let me to use: [AttributeUsage (AttributeTargets.Enum, AllowMultiple = false)] What is the right AttributeTarget value to limit the usage to enum members? 回答1: Far as I know, there isn't one specifically for enum constants. The closest you could get would probably be "Field", which limits the use to field members of a

Passing custom parameter in custom attribute - ASP.NET MVC

帅比萌擦擦* 提交于 2019-12-18 13:35:56
问题 My goal is to create a custom attribute like System.ComponentModel.DataAnnotations.Display wich allows me to pass a parameter. Ex.: In System.ComponentModel.DataAnnotations.Display I can pass a value to the parameter Name [Display(Name = "PropertyName")] public int Property { get; set; } I want to do the same but in controllers and actions like below [CustomDisplay(Name = "Controller name")] public class HomeController : Controller and then fill a ViewBag or ViewData item with its value. Can

How to solve Android Libraries custom attributes and package name remapping during build?

柔情痞子 提交于 2019-12-18 12:38:51
问题 Over time our Android project has expanded a great deal, and these days we are creating multiple branded APKs from the same source tree. This has become challenging due to the package naming requirements of Android. We have all of our shared code in an Android Library project, which is included in the main application project. Plus we have Android library 'overlays' for branded resources that get applied for each brand. When we want to build a brand, we include a few extra properties for that

Custom Attributes on Class Members

扶醉桌前 提交于 2019-12-18 12:31:36
问题 I am using a Custom Attribute to define how a class's members are mapped to properties for posting as a form post (Payment Gateway). I have the custom attribute working just fine, and am able to get the attribute by "name", but would like to get the attribute by the member itself. For example: getFieldName("name"); vs getFieldName(obj.Name); The plan is to write a method to serialize the class with members into a postable string. Here's the test code I have at this point, where ret is a

how to get product attributes from wordpress database

人盡茶涼 提交于 2019-12-18 12:09:25
问题 Writing custom code to create product detail page with wordpress database. I have displayed product title, desc, price, stock, etc and got stuck up with product attributes. In the database, _product_attributes is stored in serialized manner in wp_postmeta table in database. And i couldn't unserailize attributes from it. But i found, each attribute value with it own price has been stored in wp_postmeta in some other post_id. for example, product with post_id=55 has attribute name 'Size value'