custom-attributes

ListItem.Attributes.Add not working

青春壹個敷衍的年華 提交于 2019-12-11 03:14:47
问题 I am trying to add a custom attribute to list item but it is not adding it My code is this ListItem item = new ListItem(teamMemberGroup.Name, teamMemberGroup.ID); item.Attributes.Add("teammembergroup", "true"); ddlTeamGroups.Items.Add(item); ddlTeamGroups1.Items.Add(item); It is only adding option text and value in the Html but no attributes! My dropdown is inside an update panel but I don't think update panel is making something wrong as I am not looking for postback but it is only about the

How to pass a Type as an attribute parameter using F# syntax?

血红的双手。 提交于 2019-12-11 00:54:59
问题 FsCheck allows a custom Arbitrary in its NUnit integration: [<Property(Verbose = true, Arbitrary= [typeof<Test.Arithmetic.MyArb>])>] static member MultiplyIdentity (x: int64) = x * 1 = x This syntax doesn't work. I feel a bit embarrassed to ask, but apparently I never needed this before: how do you specify the type in F# as an attribute parameter? Microsoft says nothing about it, nor does the Wikibooks project and I have some trouble googling this (the word type is omnipresent). Note 1: the

Get custom attribute from SubClass in BaseClass (C# .NET 4.0)

淺唱寂寞╮ 提交于 2019-12-11 00:13:42
问题 Ok, edited the code for clarification: Question: How can I access the attribute [MyAttr("...")] in TestClassOne/Two from BaseClass.TheAttribute ...? All classes except TestClassOne/Two will be compiled in to my "core" and delivered as a dev-platform to a customer. The TestClassOne/Two is developed by the customer, so there can be no knowledge of the TestClassOne/Two in the "core". Code below is compiled into "core" and delivered to customer as dll. [TestMethod()] public void AttrTest() { var

Using Custom PropertyTab in System.Windows.Forms.PropertyGrid Control

六月ゝ 毕业季﹏ 提交于 2019-12-10 23:49:56
问题 I am trying to use the customisable property tab feature of the WinForms PropertyGrid control but it has me beaten. I am specifically trying to use in runtime a PropertyGrid to display object properties, as opposed to trying to create design-time support for a control, though they seem to be applications of similar technology. This question has me seriously confused. I have attempted to follow several tutorials on the topic and none come to any real solid conclusion. Literature Review http:/

Replacing HeaderText with Headertemplate in TemplateField

二次信任 提交于 2019-12-10 17:14:49
问题 I have a gridview with templatefield columns. The TemplateFields are something like this: <asp:TemplateField HeaderText="Title" SortExpression="name" meta:resourcekey="BoundFieldResource1"> <ItemTemplate> <asp:Label ID="lblTitle" runat="server" Text='<%# Bind("Name") %>' meta:resourcekey="BoundFieldResource1"></asp:Label> </ItemTemplate> I have to add a custom attribute for to the header of this columns so I removed HeaderText and added the following: <Headertemplate> <asp:Label ID=

How do I add an attribute to the field of the base class from child class?

拈花ヽ惹草 提交于 2019-12-10 17:02:28
问题 Base class: public class XmlNameValueField : XmlBaseField { [XmlAttribute("n")] [Required] public string Name { get; set; } [XmlText] public string Value { get; set; } } Child Class: public class DateField : XmlNameValueField { } In the Child class field Name must have an additional attribute [DataType (DataType.EmailAddress)] 回答1: You'll need to mark the property as virtual in the base class, override it in the child class and add the attributes. 来源: https://stackoverflow.com/questions

Is it possible to merge two C# attributes into one?

最后都变了- 提交于 2019-12-10 16:25:48
问题 I'm using EF6 code first in one of my company's projects. In the project there are a couple of properties in POCO classes that store Persian date information (for example 1394/01/24). In our database these values are stored in "CHAR(10)" columns. I use string properties to store these values in my POCOs and have to attach "ColumnAttribute" and "StringLengthAttribute" to every date property: public class MyPoco { ... [Column(TypeName="CHAR")] [StringLength(10, MinimumLength=10)] public string

C# Custom Attributes from Properties

你离开我真会死。 提交于 2019-12-10 13:56:28
问题 so I have a collection of Properties from my class which I want to loop through. For each property I may have custom attributes so I want to loop through those. In this particular case I have a custom attribute on my City Class as such public class City { [ColumnName("OtroID")] public int CityID { get; set; } [Required(ErrorMessage = "Please Specify a City Name")] public string CityName { get; set; } } The attribute is defined as such [AttributeUsage(AttributeTargets.All)] public class

How do I pass in the repository to an authorize attribute in ASP.NET MVC

蹲街弑〆低调 提交于 2019-12-10 13:46:41
问题 I am castle Windsor and it works great for controller constructors in passing in the repository that is being used. private IStoryRepository Repository; public StoryController(IStoryRepository Repository) { this.Repository = Repository; } Now I have an Action that is in the admin area to display the main admin menu. I have used a custom authorisation attribute which will just check that the logged in user is an admin (just an isAdmin flag in the users table) [AdminAuthorize] public

Change values in Class Attribute at runtime

非 Y 不嫁゛ 提交于 2019-12-10 13:19:24
问题 If I have a class like this [Attr("Blah", Data = "Blah")] public class Test : SuperClass{} Is there a way I can change the values of the attribute of an instance of the class at runtime? eg in pseudo code SuperClass test = new Test(); test.Attr.Value = "blah1"; test.Attr.Data = "blah2"; (I have an instance of the class I want to change the attributes on, cast as a class it extends) 回答1: There is no implicit connection between attributes and objects instances. Only between the class and the