default-value

C# XML Deserialization W/ Default Values

I've got an object that is being serialized / deserialized via the XmlSerializer in C#, .NET 3.5. One of the properties (and more in the future) is a collection: List where T is an enum value. This serializes / deserializes fine. We are also using a "default values" mechanism to provide default values for the object, in case the seriali...

DefaultValue atttribute is not working with my Auto Property!!

Hello, I have the following Auto Property [DefaultValue(true)] public bool RetrieveAllInfo { get; set; } when I try to use it inside the code i find the default false for is false I assume this is the default value to a bool variable, does anyone have a clue what is wrong!? ...

WPF: dependency property with type of Template - where to get default template (to set as default value)?

Hi, I am subclassing an ItemsControl (let's call it EnhancedItemsControl), and I would like to expose ScrollViewerTemplate dependency property, which would allow the user to optionally specify his own template for used ScrollViewer. I am doing it like this: public ControlTemplate ScrollViewerTemplate { get { return (ControlTemplate)G...

Overriding default property values in .Net, WinForms.

Let's say I create a class "Planet" that can be inherited. One of the purposes of inheriting is to create a template with different default property values. Eg: Public Sub New MyBase.New MyBase.ForeColor = Red MyBase.Name = "Mars" etc. End Sub Now, to stop the defaults serializing in the InitializeComponent method, the...

Drupal form_submit and default_value

I have a simple form: function mymodule_test_form(&$form_state, $nid) { form['submit'] = array( '#type' => 'submit', '#value' => 'Click me!', ); $form['mymodule_status'] = array( '#type' => 'select', '#attributes' => array('class' => 'myclass'), '#default_value' => variable_get('mymodule_status', 0), '#opti...

C# 4.0: Can I use a TimeSpan as an optional parameter with a default value?

Both of these generate an error saying they must be a compile-time constant: void Foo(TimeSpan span = TimeSpan.FromSeconds(2.0)) void Foo(TimeSpan span = new TimeSpan(2000)) First of all, can someone explain why these values can't be determined at compile time? And is there a way to specify a default value for an optional TimeSpan obj...

Edit form with default Jquery date values, jquery sets current date for field after page is loaded.

$(document).ready(function(){ $('#data_nasterii').datepicker($.datepicker.regional['ro']); // romanian language $('#data_nasterii').datepicker('option', 'changeMonth', true); // dropdown with month $('#data_nasterii').datepicker('option', 'changeYear', true); // dropdown with year $('#data_nasterii').datepicker('option', 'yearRange',...

PostgreSQL: store IP address of a connection in a table

Hi I'd like to have a column in a Postgres table which will store the remote IP address of the user connecting to the database. I'm thinking of data type "inet" with some sort of default constraint. Any ideas? Thanks. ...

Using default values in an INSTEAD OF INSERT trigger

We are performing a database migration to SQL Server, and to support a legacy app we have defined views on the SQL Server table which present data as the legacy app expects. However, we're now having trouble with INSTEAD OF INSERT triggers defined on those views, when the fields may have default values. I'll try to give an example. A ...

JavaScript/JQuery: use $(this) in a variable-name

Hi! I'm writing a jquery-plugin, that changes a css-value of certain elements on certain user-actions. On other actions the css-value should be reseted to their initial value. As I found no way to get the initial css-values back, I just created an array that stores all initial values in the beginning. I did this with: var initialCSSV...

Default values in WPF DataBinding ?

Can we set default values in WPF DataBinding? e.g : I've bound the Height and Width of my window to some properties as follows. <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" x...

Overload DataGridViewCellStyle and give a default value

I'm writing a custom DataGridView object for a large project to hand out to a bunch of developers to make our app sections look consistent. I want to set defaults for many of the properties of the DataGridView, and I can set many of them like this: <System.ComponentModel.Browsable(True), System.ComponentModel.DefaultValue(DataGridViewA...

Protected Configuration: useMachineContainer's default value?

In ASP.NET, when I'm using Protected Configuration, I'll specify something similar to the following in my web.config: <configuration> <configProtectedData defaultProvider="SampleProvider"> <providers> <add name="SampleProvider" type="System.Configuration.RsaProtectedConfigurationProvider, System.Confi...

What Namespace is the Default attribute for properties on UserControls?

I found half of the answer here to my question when searching "what is the attribute to set the default value of a User Control property in the designer where you change it and it bolds". However the answer neglects to mention the namespace it is in. Searching through Object Browser yields hundreds of classes/properties with the name D...

Non static members as default parameters in C++

I'm refactoring a large amount of code where I have to add an extra parameter to a number of functions, which will always have a value of a member of that object. Something like class MyClass { public: CMyObject A,B; void MyFunc(CMyObject &Object); // used to be void MyFunc(); }; Now, I'd actually like it to read class MyC...

Hibernate default values during runtime - best practice

Hi stackoverflow coders, I have an app (since the iPhone its really chic to use this word :-)) persisting its data with Hibernate. The database scheme contains several date fields which can be NULL. I configured Hibernate then to fetch the field value also as NULL. The customer wants to configure these values in case these are NULL. So...

What is the scope of a defaulted parameter in Python?

When you define a function in Python with an array parameter, what is the scope of that parameter? This example is taken from the Python tutorial: def f(a, L=[]): L.append(a) return L print f(1) print f(2) print f(3) Prints: [1] [1, 2] [1, 2, 3] I'm not quite sure if I understand what's happening here. Does this mean that...

grails default values

Hi! I have an application written in grails. I want to add a new domain class with default initial values. These values should appear as default or initial values under the create view. I mean, the generated inout field tag should have this value as an attribute. The class (simplified) look as follows: class Whatever{ static constrain...

ASP.NET MVC 2 / Localization / Dynamic Default Value?

Hello In an ASP.NET MVC 2 application, i'm having a route like this: routes.MapRoute( "Default", // Route name "{lang}/{controller}/{action}/{id}", // URL with parameters new // Parameter defaul...

Auto-generated values for columns in database

Is it a good practice to initialize columns that we can know their values in database, for example identity columns of type unique identifier can have a default value (NEWID()), or columns that shows the record create date can have a default value (GETDATE()). Should I go through all my tables and do this whereever I am sure that I won'...