attributes

applying and using attributes in asp.net pages

I think I may be approaching this issue wrong but here goes... I'm trying to apply attributes (non-html) to web controls through the designer such as: [MHCSecurityAttribute("testpermission", true)] protected global::System.Web.UI.WebControls.TextBox test1; The idea is to loop through the controls collection within a base page...

From a UITypeEditor, retreive an attribute applied to the parent of a property in .net

It's not quite as simple as the title says but I hope you understand. Consider this scenario: Class MyClass Property SubProp1 End Property -TypeEditor(whatever)- Property SubProp2 End Property End Class Class MyButton Inherits Button -MyCustomAttribute- Property MC as MyClass End Property End ...

What's the best practice to set html attribute via PHP?

When doing this job in PHP,one may meet this kind of issue: <span title="<?php echo $variable;?>">... The problem is that if $variable contains double quotes,should change it to \" And that's not the whole story yet: <span title='<?php echo $variable;?>'>... In this case,we need to change single quotes to \',but leave double quote...

Attribute selectors, JavaScript and IE8

I'm attempting to use attribute selectors and CSS for formatting elements. The HTML looks like: <div id="user" highlight="false">User Name</div> The CSS is: [highlight=true] { background-color: red; } [highlight=false] { background-color: white; } And then there's some accompanying JavaScript: if( foo ) { node.setAtt...

How do I prevent ASP.NET from converting the & symbol to &amp; when adding a url to a control's attributes?

This is what I'm adding and it renders the & as &amp; sharelink.Attributes.Add("addthis:url", "http://" & Request.Url.Host & "/Resources/PublicView.aspx?RID=" & R.ResourceID & "&Key=" & Key) I need it to render this ?RID=64&Key=%2fwEUKwEDAgQCFAJA instead of this ?RID=64&amp;Key=%2fwEUKwEDAgQCFAJA ...

Python Class attributes - resetting

Hi Whats the best way to reset class attributes in Python. I have a class whichs has about 20 class attributes, in my init I have class MyClass: def __init__(self) self.time=0 self.pos=0 self.vel=0 self.acc=0 self.rot=0 self.dyn=0 . These need to be reset on each iteration of my p...

Testing properties with reflection using attributes

I'm trying to create a nUnit test to do the following: 1) Load the DLL to test. 2) Iterate among the various types. 3) Find the ones that have a certain custom attribute. 4) Instantiate these types and make sure that all their public properties aren't null. Here's what I wrote so far: Assembly assembly = Assembly.LoadFile("MyLib.dll...

Localized Attribute parameters in C#

In C#, attribute parameters require to be a constant expression, typeof or array creation expression. Various libraries, like for example Castle validator, allow specifying passing what seems like localized error messages to attribute constructor: //this works [ValidateNonEmpty("Can not be empty")] //this does not compile [ValidateNon...

Extracting numbers from the parent attribute in jQuery

By clicking on the "mylink" I want the link to be replaced by the number "123", which is extracted from parent tag. I think I'm not doing the ".match(...." right. jQuery: $(document).ready(function(){ $(".link").click(function(){ var comid = $(this).parents("div.comment").attr("class").match(/comment-([0-9]+)/)[1]; $(".link")...

How do you make a column an auto incremented primary key in the various .NET ORMs?

How do you make a column (let's call it OrderID) an auto incremented primary key in the various .NET ORMs? Linq To SQL [Column(Name="OrderID", IsPrimaryKey=true, IsDbGenerated=true)] Entity Framework [EdmScalarProperty(EntityKeyProperty=true, IsNullable=false)] (Not possible to specify autoinc?) NHibernate [Id(Name = "OrderId"...

Jquery: Cloning a select list and selecting an option by its value

hello, I'm trying to append a select option list to a div table with jQuery, after done this, I'd like to select a specific option of the list, I'm trying something like this: // my hidden option list <div style="display:none;"> <select class="option_list"> <option value="male">Male</option> <option value="female">Female</option...

Define RequiredAttribute on .net model depending on current user

I'm struggling with a basic concept that is used by DynamicData in ASP.NET or the DataForm in Silverlight. I do not have code since I'm still trying to understand the mechanism. As far as I understand Attributes, the idea is to annotate the model by adding a RequiredAttribute to a property of a model class to indicate to the framework, ...

rails lazy load of model attributes

Hi! Normally rails loads data with a :select => "*" from the database. I know I could change this. But I'd like to go another way: always only select "id" and load the attributes automatically later on when they are needed. Example: accessing user.description should if it's been loaded yet. if not, trigger a "SELECT description FROM us...

Attribute, interface, or abstract class

I'm wondering what the general recommendation would be (attribute, interface, abstract class, or combination thereof) for the following implementation: /// <summary> /// Loads class specific information into a list for serialization. The class must extend PlugIn. /// The filenames parameter is passed from a FileDialog. /...

Testing that serializable attributes are set

I'm writing a unit test to verify that the serializable attributes are set on my class. I thought I was on the right way, but for some reason I can't find the attribute types. Here is my class: [DataContract] public class User { [DataMember] public int Id { get; set; } } And a unit test for checking the attributes: [Test]...

C# attribute name abbreviation

How is it possible that C# attributes have "Attribute" in their name (e.g. DataMemberAttribute) but are initialized without this suffix? e.g.: [DataMember] private int i; ...

Jquery - How to find an element using class and attribute.

I am trying to figure out the most efficient way to find my element. Following i smy structure: <div class="a" customattrib="2"> in order to find this element can I do something like : $("div.a [customattrib='2']") This does not seem to work, is there another way to do this? Without the class I am able to get the value but I do no...

Have asp.net base page property show up in @Page attribute

Hi all, I have create a list of public properties in our custom page. However, when I want to assign the property on any aspx file, it does not show in intellisense and when I use it it said it is a invalid attribute of element "Page". So, 2 question. How do I make it such that it shows up in intellisense? Can I set any localize var...

JQuery Selectors: Select element with specific class and 'title' attribute

Hi all, This should be an easy one, but I can't find a good example anywhere. I'm trying to select a particular element on my page that has a class of 'statuslight' and a title attribute of one of three options. The option (it will depend) is stored in a variable called 'currentStatus'. I've seen some examples, and I'm guessing this is ...

Reading JSON (with jQuery) produced by PHP containing @attributes

What are those "@attributes" thing I have in my JSON file and how can I read that with JQuery? The JSON "text" I use is produced with json_encode in PHP from an array of custom objects. Here's a reduced JSON file: { "movies" : [ { "url":"http:\/\/www.youtube.com\/watch?v=Nsd7ZcXnL6k", title":{"@attributes":{"type":"text"},"0":"**Title...