.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

NOT getting the defaultValue for a ConfigurationProperty

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :.NET Framework

I have a very simple Configuration Section.....

public myConfigSection : ConfigurationSection


   [ConfigurationProperty("MyValue", DefaultValue = null)]

   public string MyValue


      get { return (string)base["MyValue"]; }

      set { base["MyValue"] = value; }




My problem is that I never get null returned (as stated in the default value) I get an empty string instead.

An empty string is a valid configuration item that the business can specify for this in the configuration file. I now need to know if the the configuration file has an empty string or if it does not contain this item in the configuration file.


I have seen a few posts for this but nothings appears to provide a solution.




View Complete Post

More Related Resource Links

Which way to go? XMLElement or ConfigurationProperty?

I'm in the process of defining a class to represent an XML file. I've found 2 ways to do this: using XML serialization and associated attributes like XMLElement, XMLAttribute, as well as using custom configuration section. I feel like XML serialization is mainly for business data definition, such as Customer, Order etc, while custom configuration section is mainly for system setting parameters. Having said that, though, looking directly at the XML file per se, I don't have the good ability of choosing which way to go. So, can anyone kindly provide some knowledge on the difference between the two please? When should I choose one against another?   Thanks in advance. - Nico -You Can't Stop Me!

How To set DefaultValue of ImageUrl of CompositeControl ImageButton



how to set DeafultValue of ImageUrl to embeded resource so when Client imput's ImageUrl="~/someimege.png" his image would show but if the client doesn't imput Url Default image would show. That Url must not be visible in properties window...

<DefaultProperty("Time"), ToolboxData("<{0}:TimePickerGTI runat=server />")>
    Public Class TimePickerGTI
        Inherits CompositeControl

        Private TimeButton As ImageButton
        <Bindable(False), Category("Default"), DefaultValue("Default"), Description("UpDown Image Url.")> _
        Public Property UpDownImageUrl() As String
                Return TimeButton.ImageUrl
            End Get
            Set(ByVal value As String)
                TimeButton.ImageUrl = value
            End Set
        End Property
        Protected Overrides Sub CreateChildControls()
            TimeButton = New ImageButton
            TimeButton.ID = "TimeButton"
            TimeButton.Height = 18
            TimeButton.ImageAlign = ImageAlign.Middle
        End Sub
        Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)

DefaultValue in properties window displayed as bold / not bold ?



I would like to know why somethimes DefaultValue in properties window is displayed in bold text and somethimes in normal weight text? What i know is that the Value in Properties Window should display bold only if the Value is different than DefaultValue.

So i have a situation, where i need to set DefaultValue's and i'm successfully setting the boolean Value but failing in Integer value...


<cc1:TimePickerGTI ID="TimePickerGTI1" runat="server" />

custom server control:

        Private _ShowSeconds As Boolean = True
        <Browsable(True), Category("Behavior"), DefaultValue(True), Description("Show seconds.")> _
        Public Property ShowSeconds() As Boolean
                Return _ShowSeconds
            End Get
            Set(ByVal value As Boolean)
                _ShowSeconds = value
            End Set
        End Property

        Private _StepHour As Int32 = 1
        <Browsable(True), Cate
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