.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Property with a default value

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :ASP.Net

  I have a property defined in the UserControl. It is possible to set a default value to the property?

  Public WriteOnly Property ValidateDescription() As Boolean
        Set(ByVal value As Boolean)
            reqDesc.Enabled = value 'reqDesc is the Required Field Validator
        End Set
    End Property




View Complete Post

More Related Resource Links

The default web application could not be determined. Set the SiteUrl property in feature


I am getting this error when I deploy a BCS feature generated by BCSMetaMan:

The default web application could not be determined. Set the SiteUrl property in feature Feature_Feature1 to the URL of the desired site and retry activation.

Searching the Internet tells me I need to put in a property in my feature file that sets the default site. However, what if I need to be able to deploy this other sites. Is there a way to set the value so it will use whatever site is the solution is being deployed to?

how can i set the default value for DateTime property?



how can i set the default value of some property for DateTime ?

[DefaultValueAttribute(typeof(DateTime), DateTime.Today.ToString())

when i try this then it prompts the below error?

How To define a Default Value for an enum property serializable ?


I'm trying to use the default value attribute. But, when deserializing the default value is not set to what specified with DefaultValueAttribute. Here is an exerpt of my code :

public class MyClass
  public string Name { get; set; }

  [DefaultValue(typeof(Color), "Blue")]
  public Color PropA { get; set; }

  public Color PropB { get; set; }
public enum ErrorLevel
  Red, Blue, Green

The XML not the result of a serialization. Someone have to write it. Here is a sample :


How to set default Height/Width property value of Composite control?

This is my code:

class Regi : CompositeControl
private TextBox nameTextBox;    

[DefaultValue(typeof(Unit), "400px")]
public override Unit Width
return base.Width;

Custom Controls derived from existing controls - overriding default property values


I have some (probably very basic) questions about developing custom controls.  I am wanting to derive a set of button controls, and the first one I have started on is a "DeleteButton", that has a additional property (DeleteConfirmationText) that is built into the OnClientClick attribute.  To get that added, I overrode the Render method as follows:

protected override void Render(HtmlTextWriter writer)
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Format("return confirm('{0}');", this.DeleteConfirmationText));

This all works well.  Now, I will add some logic to make sure that there is some text in the DeleteConfirmationText property, but that isn't the intent of my question.

What I am also wanting to do is to override some of the default property values, so I added that to the default constructor:

public DeleteButton()
            // Default the command name, and the button text to "Delete".
            this.CausesValidation = false;
            this.CommandName = "Delete";
            this.Text = "Delete";

Now, in the designer in VS2008, and I look at the properties for the control, there isn'

How to change default category for the Text Box Property NUMBER across multiple textboxes


I'm using SSRS R8 and have several reports with numerous NUMERIC textboxes.  The default NUMBER category that SSRS applies is "Default", which applies no formating to the number values shown in the textbox.  When the report executes, it displays these values with 4 decimal places (e.g. 123.1234).  The customer requires 2 decimal places (e.g. 123.12). 

This can be easily fixed by changing the category for the NUMBER Text Box Property from "Default" to "Number", with "Decimal Places" set to 2.

The trouble with doing it this way is that each report has over a hundred such textboxes (there are 15 such reports), and to change each textbox individually would be timeconsuming and error prone.  The intuitive way to do this would be to select multiple textboxes that I want to set the NUMBER category for, right click, select Text Box Properties, and set the NUMBER category accordingly.  However when I right click the multi-selected text boxes, I see the Text Box Properties option greyed out.

Is there a different way to do this?

Default ASP.NET Architecture

In providing an architectural approach, some assumptions are made concerning the project goals. These assumptions should be used as a litmus test to determine if the described architecture may be an appropriate fit for your ASP.NET application.

WPF / Silverlight tutorial: Visibility property and binding

Visibility property is a very powerful and yet often overlooked property available in both WPF and Silverlight. It enables you to set Visibility of certain UIElement objects to different states like: Visible, Collapsed and Hidden (not supported by Silverlight). This tutorial shows you how to use it and how to bind to Visibility property

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

Setting the default start page in godaddy hosting?


 How do you set the start page with godaddy hosting? I can see no way of doing this! You do not seem to have access to the IIS settings that allow you to change it!

default constructor SelectList




dont have a  default constructor

new SelectList() :(

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo

How to change the default page base class?


I've tried setting the <pages pageBaseType="DynamicWebPage" /> value in web.config, but when I response.write out the page type, I'm still getting Microsoft.WebPages.WebPage.

I'm simply trying to sub-class WebPage and add some additional functionality such as a dynamic PageData dictionary similar to Phil Haack's dynamic ViewData dictionary.



Default page for my Forlder(product)?


Hai all,

         I need to show the URL like this http://www.saffronrouge.com/face/moisturizers

for me  http://www.mysite.com/products/

i need to list all the products. please help me on this.

Is it possible to populate property choices from a database?


I'm creating my first server control, and have it working where I can set up an enum and the user can set a property's choices,  based off of that enum.  But I'd like it to pull records from a database and populate the list of choices for the property from a database.  This would allow me to add a new "Host System" to the database, and the other designers wouldn't have to get a new copy of the dll.



Custom Server Control Property not maintaining state


I have created a server control consisting of a TextArea and a div under it.  My goal is to create my own asp:TextArea type control.  the div is for a Character count of the text area and seems to work ok but i added a CharacterCountVisible property to the control that is always returning true.  See Proptery definition below


<Bindable(False), Category("Appearance"), DefaultValue("True"), Localizable(True)> Property CharacterCountVisible() As Boolean
        Return _CountBoxVisible
    End Get
    Set(ByVal value As Boolean)
        _CountBoxVisible = value
    End Set
End Property

Note the _CountBoxVisible variable is define inside the class as :

Dim _CountBoxVisible as Boolean = True

What I am trying to do is give the user/coder the option to show/utilize the char count feature.  Can make it disappear with textarea1.CharacterCountVisible = False but setting it to true will not make it display.


What am i missing





ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend