p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

aspdotnet_website_programming thread: Custom Server Control problem

Message #1 by andrew@s... on Tue, 4 Mar 2003 22:36:43
I was wondering if anyone could help me with a simple problem:

I plan to create several asp.net server controls which use one xml file.

I have created a class (called Settings) which reads the xml file, exposes 
various elements as properties or arrays, and performs other common 
tasks.  The class is in the same namespace and assembly.

I have referenced the class in my server control, but when I set the 
XmlFile property at design time, it does not work.  Here is the simple 

      public class xxx : System.Web.UI.WebControls.WebControl
            private Settings mysettings = new Settings();
            /// <summary>
            /// The xml configuration file
            /// </summary>
            Description("The xml file containing configuration settings")]
            public string XmlFile
                  get { return mysettings.XmlFile; }
                        //read in xml script and set properties
                        if ((value == string.Empty) || (value == null))
                              throw new ArgumentException("xxx requires an 
XML settings file.");
                        //map the path
                        mysettings.XmlFile = 

When I drop the control at design time, not only is the XmlFile setting 
blank in the property window, but when I add an entry, I get this error:

Invalid property value

Object reference not set to an instance of an object.

Thanks for any ideas,


  Return to Index