Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

Gottlieb.NET

David Gottlieb

  • Latest Blog Postings Now Available On DevAdvice Sites

    When you visit any of the DevAdvice sites i.e. (aspadvice.com, xmladvice.com, sqladvice.com, regexadvice.com, windowsadvice.com), you should now see a section with the latest blog postings for the blogs on that site. I added this feature last night in hopes that it would give you better notification of new postings that might be of interest to you. Hope this helps.

    Also, if you would like to see something on the advice sites, let me know and I'll certainly look into it.

  • ASP.NET 2.0 w/ VS.NET 2005 Beta 1 Has Arrived

    I go home for lunch and with perfect timing, the DHL guy rings my doorbell with a package. I had no idea what it was until I realized this was the reason why I decided not to download the latest release, Beta 1 has arrived.

    Stay tuned for comments, updates and rants about this outstanding technology!

  • Don't Leave Your Web.config Alone In The Dark

    The web.config doesn't look like much, but it is your best friend when it comes to configuring your application to perform a certain way, display a certain way and many other things that can make your life a whole lot easier.

    In my opinion, one of the most important things about the web.config, that most of us seem to neglect, is the ability to add any value you feel could change at any time on the site that normally would require a recompile and a code push. Some people feel that filling your web.config up with keys in your area is messy and can become a pain to manage. Well, they are partially correct. The appSettings section can be useful for values that are used frequently in different areas of your site. However, the draw back to that is that they are simply key/value pairs, meaning that you are limited to a key and a value and nothing more. Say for instance you want to configure how an image is displayed by specifying the width, height, alternate text and the image url. Using the standard key/value pair dictionary provided for you in the web.config just won't give you what you need to make this happen.

    An easy solution to this is to create your own section handler to handle any sort of XML you would like to add to the web.config with the added functionality for easy readability and portability.

    Below is a snippet of code I have written so that I can add pieces of configuration to my web.config with as much detail as I need to store.

    using System;
    
    using System.Data;
    using System.Xml;

    namespace AspAdvice.Configuration
    {
    ///
    /// Summary description for ConfigSectionHandler.
    ///

    public class AspAdviceConfigSectionHandler : System.Configuration.IConfigurationSectionHandler
    {
    public AspAdviceConfigSectionHandler()
    {

    }
    #region IConfigurationSectionHandler Members

    public object Create(object parent, object configContext, System.Xml.XmlNode section)
    {
    //section.
    return new AspAdviceConfig(section.ChildNodes);
    }

    #endregion
    }

    public class AspAdviceConfig
    {
    private System.Xml.XmlNodeList nodesHere;

    internal AspAdviceConfig (System.Xml.XmlNodeList configNodes)
    {
    nodesHere = configNodes;
    }

    public XmlNodeList GetXmlNodeList()
    {
    return nodesHere;
    }

    public DataTable ToDataTable()
    {
    DataTable myTable = new DataTable();

    if (nodesHere.Count > 0)
    {
    for (int x=0;x {
    myTable.Columns.Add(new DataColumn(nodesHere.Item(0).Attributes[x].Name));
    }

    for (int i=0;i {
    DataRow myRow = myTable.NewRow();
    for (int e=0;e {
    myRow[nodesHere.Item(i).Attributes[e].Name] = nodesHere.Item(i).Attributes[e].InnerText;
    }
    myTable.Rows.Add(myRow);
    myRow = null;
    }

    return myTable;
    }
    else
    {
    throw new System.Configuration.ConfigurationException("There are no elements beneath the specified config section");
    return null;
    }
    }
    }
    }
    The code above simply takes the configuration section you specify and runs it through the method you specify, such as ToDataTable() or GetXmlNodeList() and returns it to you so
    that you can easily navigate through it and grab your values. So now, we can take something such as:



      ”Hello”
      ”Dog”
       
      “Dog“

    And easily navigate through it now using your custom configuration section handler we have written. Now, keep in mind that beneath your section, you will need to add the following tag:

      

    This tag tells .NET to use the AspAdvice.Configuration.AspAdviceConfigSectionHandler class to read this config section and that it is located in the ASPAdvice.Library assembly.
    To implement this, you would simple add this snippet of code:
      DataTable images = ((AspAdvice.Configuration.AspAdviceConfig)System.Configuration.ConfigurationSettings.GetConfig(“Images")).ToDataTable();
      or
       XmlNodeList imageList =  ((AspAdvice.Configuration.AspAdviceConfig)System.Configuration.ConfigurationSettings.GetConfig(myConfig["Domain"].ToUpper() + 
    "/Sponsors")).GetXmlNodeList();
    Hope this was helpful. I would love to hear that if you use this, how it helped you. Keep posted for upcoming snippets and tutorials.
  • Recommended RSS Reader

    I find that going to visit every blogs site that I keep up with is just tedious and inconvenient. A friend of mine recommended SharpReader to keep up with all of the blogs I read.

    It's actually quite nice in that any time new posts come about, you get a little toast pop up on the bottom right hand corner of your screen. Another neat thing is that you can share your blog lists with friends by exporting your list of blogs and passing them along for others to import. I would also like to add that you don't even have to point it to the actual rss feed. All you have to do is go to the blog site and it will search and find the feed for you. Quite nice!

  • DotNetNuke Rocks!

    I have been neglecting my personal web site because I just haven't had the time to get it up and running. I figured I would mess around with DotNetNuke for my site.

    I had heard a lot of good things about it and have seen some pretty impressive implementations of it.  I put ftp'd it up to my server and got it running immediately.  This framework that they have developed is extremely powerful.and would definitely recommend that everyone download it and at least go through the code to see how they are doing things.

    They have implented objects called Modules which are objects such as Links, Login, Banners, Contacts, Events calendar etc. You can add these modules any where on the page and admin their content. This is a huge benefit to a developer that needs to get a site up quickly and turn it over to the client. I have not yet had to make a code change to get this code to do what I want it to do. Download it!

  • At .NET Connections Conference

    It is day 3 of the Connect ions conference here in Orlando and things have gone very well. I have listened to a couple of good talks on the upcoming .NET 2.0, met some wonderful people and got to talk to some other developers to get a feel for what everyone is doing out there with this incredible technology.

    Steve Smith, his wife Michelle, their daughter Ilyana and I have been promoting the new DevAdvice.com site that we have running for the community. For promotions, we have given out 500 juggling sets, 2 copies of VS.NET 2003, a copy of SQL Server 2000 and a couple other software packages for prizes. Things have gone very well and I think we have gotten the word out that DevAdvice.com is the place to go to get answers to questions from the pros.

    For those of you reading this blog because you were directed here from us at the booth, it was great meeting you and hope that this becomes a place you frequently come to for help, ideas, and to communicate with other people in our field with any questions or answers you may have.

  • Off To The .NET Connections Conference I Go!

    I'm all excited now because I am headed to Orlando, FL for the .NET Connections conference in April. I am going to be co-running the DevAdvice.com booth with Steve Smith. I am hoping to learn a lot while I'm down there and meet a lot of the people I have dealt with via lists, blogs, forums etc. If you happen to have the privilege of going, please make it a point to stop by the DevAdvice.com booth. I would love to meet you and talk .NET for a bit and exchange ideas.

    See ya' there!

  • .NET Web Service or .NET Remoting?

    I was recently tasked with writing a chat client to service customers via the web site with technical support and customer questions.  The first thing that came to my mind was, “Woo Hoo! I get to play with .NET Remoting!”  As I began doing my research, I figured that this could be done in one of two ways - .NET Web Services or .NET Remoting. 

    Obviously, in a chat application you will want each client running the application to interact with the other right?  Well, this requires an object that contains state.  Web services are stateless, therefore they would not work for this application.

    When the client attempts to communicate with the proxy, which is responsible with communicating with the server and whose responsibility is to invoke objects and methods on the server, there are two types of server activated objects, Single Call and Singleton.

    The single call object includes the client making a call to the proxy which invokes the object on the server, once created and it has done what it needs to do, it is marked for the garbage collection to pick it up next time around.  Thus, the Single Call object is stateless and this is not what we are looking for.

    The Singleton object is a stateful object in that the object will maintain its state in between calls from the client and allows other clients that are communicating through the proxy to interact with each other. 

    Just wanted to give a little background in remoting and why this solution fit my needs better than web services. I will come back with updates as I progress in this application.  There is a lot to be learned in .NET remoting! I definitely recommend reading up on it.

More Posts « Previous page