Tuesday, March 16, 2010

I’m pretty excited about two upcoming events coming to our community and I have an active role in both of them. 

First, I’ll be presenting at the .Net Data Access Firestarter on March 17, 2010.  This event, hosted at the Microsoft Office in Malvern, PA covers a variety of .Net data access strategies including LINQ to SQL, WCF Data Services and OData, Entity Framework, and even Azure Data Storage.  It’s a pretty good variety of information.  I’ll be doing one of the earliest sessions on the day, my topic is “Introduction To LINQ”.  I’m excited about this because LINQ is such an important part of the .Net Framework now.  While it isn’t really a data access technology, most of the data access technologies use LINQ!  It should be a lot of fun and I am honored to be a part of the event.  Also, if you can’t make it out to the event, you can watch it online too!

Here is a link to more information.

Second is of course, Philly.Net Code Camp.  Our next Code Camp is April 10, 2010.  Once again we are back at DeVry University.  These Code Camps just continue to get better and better.  Once again, we 60 sessions in a variety of technologies.  In addition, we are broadcasting a portion of the content via Live Meeting and they’ll also be available for download later.  That alone makes this an exciting event.  This year, we’ve also invited some folks from Alex’s Lemonade Stand to come by.  At the end of the day, we’ll be presenting them with a donation to their worthwhile organization.  How are we raising the money?  This year we are offering two kinds of tickets to Code Camp.  The first is the standard, free ticket.  Anyone is welcome to come to Code Camp for free and enjoy the day (and breakfast and lunch are included as always).  But we have added a Booster ticket this year for $25.  If attendees choose to donate this small amount, they get a few benefits:

  • $5 of the each Booster ticket goes to Alex’s Lemonade Stand
  • Boosters are included in some premium raffles
  • Boosters are included in the post Code Camp party
  • Booster money will help sustain Philly.Net throughout the year.
  • Other benefits are included as well.

This is sort of an experiment.  The leadership, of which I am a member, doesn’t know how this will turn out.  It seems to me that $25 is a small price to pay for a ton of content at Code Camp, not to mention the fact that we provide breakfast and lunch.  And we hope that people won’t mind donating to our efforts, it takes a lot of money to run the organization and all of the events year round.  Plus, we are donating a portion to charity.  On the other hand, I always liked these events being free.  People donate their time so that others can come and learn for free.  It’s a great concept!  But times are changing and we need money to run our organization year round.

In any case, whether you choose to donate or attend for free, I hope to see you at Code Camp.

Tuesday, March 16, 2010 10:21:58 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, April 23, 2009

jQuery rocks.  It makes it really easy to do cool stuff client side with JavaScript, like these cascading DropDowns (aka Select Lists).  But at the end of the day, jQuery is JavaScript, and it can still be tricky to work with.  One of these days, Visual Studio will treat JavaScript like a first class language and life will be much easier.  You'll see that there isn't much JavaScript here, but it took me several iterations to get this right.

I'll start with the UI code and JavaScript.  If you want, you can read further and see the Controller code and more.

In my View, I have two DropDowns (Select Lists) and some JavaScript:

<p>
    Country:
    <%= Html.DropDownList("Countries", ViewData["Countries"] 
             as List<SelectListItem>) %>
</p>
<p>
    Region:
    <%= Html.DropDownList("Regions", new List<SelectListItem>()) %>
</p>

<script src="../../Scripts/jquery-1.3.2.js"></script>

<script type="text/javascript">
    $(function() {
        var countries = $("#Countries");
        var regions = $("#Regions");
        countries.change(function() {
            regions.find('option').remove();
            $.getJSON('/Home/Regions', { countryId: countries.val() }, function(data) {
                $(data).each(function() {
                    $("<option value=" + this.RegionId + ">" + this.RegionName + "</option>").appendTo(regions);
                });
            });
        });
    });
</script>

The Countries DropDown is pre-populated with data passed in ViewData. 

The second DropDown, Regions gets loaded when Countries changes.

Here's how the JavaScript and jQuery stuff works...

First I get the two Select Lists, using jQuery and the ID as the selector (jQuery makes it easy!):

        var countries = $("#Countries");
        var regions = $("#Regions");

Next I wire up the change event on the Countries list to an anonymous function (jQuery makes it easy!):

        countries.change(function() {
        // ...
            });

Inside that function I do a few things.  First, find all options in the Region Select List and remove them:

            regions.find('option').remove();

Next I need to get the data for the second Select List. Guess what?  jQuery makes this easy too.  Using the getJSON() method, I supply the Controller and Action, as well as the Id of the country so I can get the correct regions.  I also declare a function to call when the JSON result comes back:

        $.getJSON('/Home/Regions', { countryId: countries.val() }, function(data) {
        // ...
        });

The last thing to do is load all of the results into the Select List.  This actually was the hardest thing to do but in the end it is very little code.  I tried using jQuery to create options and adding them to the select list.  I tried creating a list of options and setting the html value of the Select list.  I tried a bunch of stuff.  But this worked great... Iterate over the results with jQuery's .each function and call a function for each iteration.  The function creates some dynamic html and appends it to the Region list.  I must admit, I was surprised this worked.  I'd assume that appending would put it after the select list (<select id="Regions" />) but it actually put it inside it!

        $(data).each(function() {
            $("<option value=" + this.RegionId + ">" + this.RegionName + "</option>").appendTo(regions);
        });

That's it!  It works great.  Of course there are more complex ways to do this, with caching etc.  This is just one way to accomplish the goal.

Here's some code from the Controller that helps make it work.  Just remember, this is demo code.  I'm not too worried about separation of concerns and similar details. In a production app, I'd be calling more services!

In the Index Action (in this sample the Select Lists are in my Index View) I load the countries list into ViewData.  Again, this is a demo and that may not be the best practice.

    public ActionResult Index()
    {
        ViewData["Countries"] = GetCountries();
        return View();
    }
    private List<SelectListItem> GetCountries()
    {
        List<SelectListItem> countries =
            _countryList.Select(c => new SelectListItem {Text = c.CountryName, Value = c.CountryId.ToString()}).ToList();
        countries.Insert(0, new SelectListItem{ Text="", Value = "0"});
        return countries;
    }

Then I have a Regions Action that returns the JSON result with the values to add to my Regions Select List:

    [AcceptVerbs(HttpVerbs.Get)]
    public ActionResult Regions(int countryId)
    {
        return Json(_regionList.Where(r => r.CountryId == countryId).Select(r =>
                                                                            new
                                                                                {
                                                                                    r.RegionName,
                                                                                    r.RegionId
                                                                                }));
    }

 

That covers most of it.  Happy coding.

Technorati Tags: , ,
Thursday, April 23, 2009 7:30:44 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [3]  |  Trackback
 Wednesday, April 22, 2009

When using strongly typed views, don't name the controller action arguments with the same name as another form value!

I've been working with ASP.NET MVC for a couple of months now.  It is really pretty awesome.  It's worked so well, I haven't had much to blog about!  The other day I ran into an issue so I'm sharing the solution.   MVC will "automagically" bind the parameters of a controller action based on the values in the form.  And if your View is strongly typed and your controller action has a parameter of that same type, it will bind it too.  But in my case, the parameter was null.  MVC wasn't loading it. And there was no exception to help me out.

Here's a simple demo, I'm not showing every line of code...

 

Typical for an MVC application, I have a view that is strongly typed:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<OrganizationRole>" %>

 

The View has a simple form which includes two text boxes:

<p>
    <label for="OrganizationName">OrganizationName:</label>
    <%= Html.TextBox("OrganizationName") %>
    <%= Html.ValidationMessage("OrganizationName", "*") %>
</p>
<p>
    <label for="Role">Role:</label>
    <%= Html.TextBox("Role") %>
    <%= Html.ValidationMessage("Role", "*") %>
</p>

 

A button on the form posts back to the controller, calling the Create Action.  Here is Action Code:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(OrganizationRole role)
{
    // Do Something Here...
    return View();
}

In the screenshot below, you can see that when I debug the app, the role parameter has not been loaded.

image

The fix was simple but it took a while to figure it out!  All I had to do was re-name the parameter from "role" to "organizationRole":

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(OrganizationRole organizationRole)
{
    // Do Something Here...
    return View();
}

You see, I was being lazy and abbreviated the argument's name.  That is ok, you can name the parameter almost anything you want.  But I gave the parameter the same name as one of the other form variables!  Notice above that my form has a text box named "Role"!  MVC tried to load the values of my parameters - it takes each of the posted values from the form ("OrganizationName" and "Role") and tries to match them up with arguments with the same names (it is not case sensitive) if they exist.  It also tries to load the entire form value (strongly typed as the class OrganizationRole) to the argument of type OrganizationRole, if one exists.  But an argument of type OrganizationRole with the name "Role" screws the who thing up!  The only problem is that it doesn't throw any exceptions.  Anyway, I changed the name and presto, it works.

Wednesday, April 22, 2009 9:01:18 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, February 13, 2009

One thing I really hate about doing Silverlight development is trying to search for good information on the Internet.  When I look for a solution to a problem I am having, I always run into a lot of "noise" in the form of outdated posts that aren't relevant anymore.  There are a ton of questions, answers, and sample solutions on the web from developers working with the Silverlight 2 Beta release.  I know this was all helpful information to share at the time, but a lot of it is useless now.  The problem is, sometimes you have to read the post a bit in order to figure out that the developer was on the Beta.  I've gotten to the point where the first thing I do is look at the date on the post before I read on.  What makes this even more complicated, is sometimes the information in these posts is still relevant and very helpful! 

Oh well, at least we are lucky to be developers in an age where so much information is shared among members of the community.  Can you imaging having to read manuals for all your information ;) ?  I don't mean to discourage anyone from posting.  Don't take me too seriously, I'm just ranting.

Friday, February 13, 2009 8:45:17 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [4]  |  Trackback
 Tuesday, February 10, 2009

The other day I was working on a Silverlight app when I got this error:  Layout Cycle Detected.  The good news is that Silverlight actually gave me an error message that meant something.  That is unusual for Silverlight.  Of course the message didn't tell me what caused it, or how to fix it!  Luckily, there is this thing called the Internet ;-).  I found some information on David Yack's blog (I don't know him) that helped.

It turns out that Silverlight doesn't like it if you put too many TextBoxes in a ListBox (or possibly any other "repeater" kind of list control).  I'm not sure why it only applies to TextBoxes and not other controls, but here is my understanding of the problem...  Each time you add a TextBox to a ListBox it needs to figure out how much space to give the control, as well as all the other controls around it.  It figures that out, and then sizes all of the controls that don't have specific sizes set, and then lays everything out for you.  But I guess in a list, it needs to do this over and over and over again and Silverlight thinks it has gone into an endless loop, so at a certain point it cuts it off and says "Layout Cycle Detected".  Each time a control gets resized, the controls around it get resized, and that goes on and on until you get to the top level control.  I guess I can understand that it could be a problem, but I think the developers at Microsoft have got to come up with a better way to resolve this.  If I want to put a lot of TextBoxes in a list, I should be allowed to do so!  Also, the limit is supposedly 250 TextBoxes, but I am pretty sure I had less than that.

There are a few ways to get around the problem, as far as I know.  In my case there are a bunch of controls that made up the DataTemplate for my ListBox.  Since they are in a StackPanel, I put a fixed size on the StackPanel.  That prevents the "bubble up" of resizing going all the way to the page level.  That seemed to fix my problem most of the time, but not all of the time.  I could probably have kept playing with the layout and putting fixed sizes on more panels.  Instead, I gave in. 

I didn't want to fight with Silverlight any more so I changed all of my TextBoxes to TextBlocks.  Then I set the the ListBox items up so that you can switch them into "Edit Mode".  The problem here is that the ListBox doesn't have built in support for that.  So here is how I did it.  By the way, this is not dependent upon the "SelectedItem" in the ListBox, so you can have multiple items in EditMode at the same time.

The purpose of my list is to display a list of Services to the user.  My ListBox is bound to a collection: ObservableCollection<ServiceListItem>.  ServiceListItem is just a class that represents my data.  Among it's other properties, the ServiceListItem has a property for IsInEditMode.  It is nothing fancy:

            public bool IsInEditMode
            {
                get { return _isInEditMode; }
                set
                {
                    if (_isInEditMode == value)
                        return;
                    _isInEditMode = value;
                    NotifyPropertyChanged("IsInEditMode");
                }
            }
            private bool _isInEditMode;

In my DataTemplate for the ListBox I have two StackPanels, one for ReadOnly mode and one for Edit Mode.  The ReadOnly template has a button to switch to EditMode.  The EditMode template has two buttons.  The Cancel button reverts the data to it's original state and switched to ReadOnly mode.  The Save button saves the data and switched to ReadOnly Mode.  Here is the one that puts the template into Edit Mode (nothing fancy here):

<Button x:Name="EditService" Click="EditService_Click">
    <Button.Template>
        <ControlTemplate>
            <Image Source="../images/pencil.png" 
                   Height="10" 
                   Width="10" 
                   Cursor="Hand" 
                   VerticalAlignment="Center" 
                   HorizontalAlignment="Center"/>
        </ControlTemplate>
    </Button.Template>
</Button>

The code for the button click is pretty simple too:

        private void EditService_Click(object sender, RoutedEventArgs e)
        {
            ServiceListItem item = (ServiceListItem)((Button)sender).DataContext;
            item.IsInEditMode = true;
        }

Actually, the only cool part of this is how the control figures out which StackPanel to display.  Each one has it's Visibility Property bound to the IsInEditMode property!

                           <StackPanel x:Name="EditPanel"
                                       Visibility="{Binding IsInEditMode, Converter={StaticResource BoolVisibilityConverter}}" 
                                       Orientation="Horizontal" Height="20" >

The trick is the Converter.  We're using a Converter that converts a boolean value into a value from the Visibility Enumeration:

 

    public class BoolVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || string.IsNullOrEmpty(value.ToString()) || !(bool)value)
                return Visibility.Collapsed;

            return Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // we don't need it to convert back but we could implement that later.
            return value;
        }
    }
Don't forget to add the Converter to your user control's resources:
    <UserControl.Resources>
        <ClientUtilties:BoolVisibilityConverter x:Key="BoolVisibilityConverter" />
        <ClientUtilties:BoolInverseVisibilityConverter x:Key="BoolInverseVisibilityConverter" />
    </UserControl.Resources>
And it all just works!
From this, you should be able to figure out the other end of this, switching back to Read Only Mode. 
I hope this helps.  
Tuesday, February 10, 2009 10:01:36 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [1]  |  Trackback
 Monday, November 24, 2008

Tonight at Philly.Net we are having our annual "15 Minutes of Fame" meeting.  That is where we have 10 of our regular presenters do a short 15 minute presentation on something they think is cool.  We've got a great line up planned for tonight and I am excited to not just present my topic but also learn a few things.  These mini presentations give the audience just enough to get started, plant a seed, wet your whistle, etc. 

It's not always so easy to come up with an idea for such a short presentation.  I thought LINQ Compiled Queries was a good one because, while it is a big feature of LINQ, it is relatively easy to implement.  I also think people avoid it because it sounds complicated.  In fact, it is not. 

I'll demonstrate with some code taken from this VS2008 solution.

Here is a regular method that takes a few parameters, executes a "SELECT" on the Northwind Customers table, and returns a list of Orders.  You'll also note that there are parameters to support paging, a common scenario with LINQ.

public static List<Order> GetOrdersNotCompiled(string custName, string shipCountry, int skip, int take)
{
    //even though the query is compiled, you can still pass in parameters. 
    using (NorthwindDataContext db = new NorthwindDataContext())
    {
        List<Order> orders = (from order in db.Orders
                              where order.Customer.CompanyName == custName
                                    && order.ShipCountry == shipCountry
                              select order).Skip(skip).Take(take).ToList();

        return orders;
    }
}

So how to convert this to a Compiled Query?

A Compiled Queries get stored as a Static Func<>.  A Func acts as a "pointer" to a method.  We make it static so it can be reused across the application.  That is how we get the performance gain.  Once the .Net framework figures out how to take the LINQ and turn it into a SQL statement, it gets saved for reuse in the Static variable.

A Func<> has a limited number of parameters that can be passed to it.  I like the technique of standardizing what gets passed in, passing the datacontext in the first parameter and a "helper class" containing all other parameters as the second.  And of course, last is the out parameter.

Here is our helper class:

private class GetOrdersInputs
{
    public string CustomerName { get; set; }
    public string ShipCountry { get; set; }
    public int Take { get; set; }
    public int Skip { get; set; }
}

Now let's look at the Func<> declaration:

private static Func<NorthwindDataContext, GetOrdersInputs, IQueryable<Order>> GetOrdersQuery =
    CompiledQuery.Compile((NorthwindDataContext db, GetOrdersInputs inputs) => LINQ GOES HERE );

You can see that the Compile method takes a lambda expression.  I thought it was easier to follow without the complete LINQ.  Here is the complete version:

private static Func<NorthwindDataContext, GetOrdersInputs, IQueryable<Order>> GetOrdersQuery =
    CompiledQuery.Compile((NorthwindDataContext db, GetOrdersInputs inputs) =>
                          (from order in db.Orders
                           where order.Customer.CompanyName == inputs.CustomerName
                                 && order.ShipCountry == inputs.ShipCountry
                           select order).Skip(inputs.Skip).Take(inputs.Take));

Don't worry if the Func<> seems confusing.  You'll find it very easy to use over and over again, just replace the variables and the LINQ statement anytime you need it.

Now you just call GetOrdersQuery as follows:

public static List<Order> GetOrdersCompiled(string custName, string shipCountry, int skip, int take)
{

    // load up the helper class with parameters.
    GetOrdersInputs inputs = new GetOrdersInputs { CustomerName = custName, ShipCountry = shipCountry, Skip = skip, Take = take };

    // even though the query is compiled, you can still pass in parameters.
   
using (NorthwindDataContext db = new NorthwindDataContext())
    {

        // Execute the compiled query.
        List<Order> orders = GetOrdersQuery(db, inputs).ToList();
        return orders;
    }
}

Results:  The included demo is a little Console App that runs each query 27 times.  I'm using a free tool - CLR Profiler from Microsoft to analyze my application.

The compiled query executes about 257 thousand method calls (that is .net converting the LINQ into SQL).  But the non compiled version executes about 2.6 million calls because it does the work over and over again!

CLR Compiled

 

The Compiled Query will perform much better and it really wasn't much work to implement.  So give it a try!

Again, here is the source code:  CompiledQuery.zip

Technorati Tags: ,
 | 
Monday, November 24, 2008 1:17:41 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [3]  |  Trackback
 Monday, October 13, 2008

Philly.Net Code Camp was great.  We had over 400 people attend and the feedback is very good.

I had a great time with my presentation "Make the Switch to LINQ - Working with data will never be the same".  Thanks to everyone who joined me.  It was pretty crowded.  Thanks to those of you who stood up or sat on the floor.  I know that I covered a lot of information in my session.  I hope I didn't go to fast.  I promised that I'd have my Code Camp presentation up on my blog by today.  I'm running a little behind schedule.  Update:  here it is!  On schedule, even if it is 10:30 at night!

I've included a db create script, all of my source code, and the slides.  I have tried to add more comments to the code so it makes sense.  At the end I was pretty rushed and didn't explain all of the samples but I hope they speak for themselves.

If you have any questions, just ask... you can contact through the link on my blog.  I've also included my address in a ReadMe.txt doc in the zip file.

LINQ Demo.zip (900.4 KB)

Now, make the switch to LINQ!

 |  | 
Monday, October 13, 2008 5:16:55 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, October 07, 2008

If you haven't checked out the CLR Profiler, it is a pretty cool tool.  It's free from Microsoft and it allows you to do some profiling of applications - apps, services, or asp.net sites.  It may not compete with the high end fancy profilers that are available for purchase, but you get some decent functionality for free.

I'm no expert on this product, in fact, I have only used it a few times to do a few specific things.  Last night I needed to use it on my laptop (never had it on that machine before) and I found myself struggling to get it up and running.  The weird part is that it felt strangely familiar, like I had the same problem when I used it a few months prior.  So I'm writing this post for 2 reasons.  Hopefully it will help you if you have the same problem.  And also, hopefully in a few months when I start it again, if I hit the same problem, I'll search the Internet and find this post that I am leaving for myself!

First, make sure you have the correct version of CLR Profiler.  There are two versions available.  .Net Framework 1.1 and .Net Framework 2.0.  There is no version for the .Net Framework 3.5 but don't worry, the 2.0 version will do that trick.  The two versions look the same and surprisingly, if you search for CLR Profiler, most of the links that come up are for the 1.1 version.  So here are two links:

Now here is the part that got me this time...

I kept getting this message:  "Waiting for application to start common language runtime".

image At the time, I was using Remote Desktop to my laptop.  That may have had something to do with my issue, but I'm not sure.  I re-installed CLR Profiler to make sure I hadn't installed the wrong version.  Same problem happens! 

imageBut then I had a flash of genius (ok, maybe not genius) and my problem was solved:  I right clicked the CLRProfiler.exe and used "Run as administrator".  Everything works great.  Interestingly, it works for me today without using "Run as admin".  So was it my Remote Desktop interfering?  Could be.  But the bottom line is, "Run as administrator" solved the problem.  I hope this helps you too.

Tuesday, October 07, 2008 7:13:28 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [5]  |  Trackback
 Wednesday, September 24, 2008

NoDeNUG, The Northern Delaware .Net Users Group has been going strong for a year now!  Wow time flies.  The success of this group is due to the hard work of John Baird for running the group.  They've also had a great partner in Diamond Technologies for sponsoring all (or at least most) of their meetings for an entire year.

For a few years people in the area wanted to start a .Net User Group in Northern DE.  A year ago, John, Mitch Ruebush, Doug White and myself finally got it going.  Dani Diaz helped of course.  Plus Nate Sharp (Diamond Tech) supported the group from the start, and since he and I worked for Diamond, owners Chuck Burns and Greg Ballance offered to host the first few meetings and sponsor one of them.  I think we were all pleasantly surprised that the first meeting had about 15 people, if my memory serves me correctly.  The second meeting had more, and it grew each month.  Diamond offered to host and sponsor the meetings for the year.

After the first few meetings, I was unable to help out anymore since I got a new job and wasn't working in DE anymore.  It's an hour from my home and I'm pretty busy with Philly.Net anyway.  But John has really done a great job with the group and it's been growing and growing.  They moved out of Diamond's office due to size constraints and now host meetings at Delaware Technology Park but Diamond continues to sponsor the meetings.  I hope to make it to some meetings soon, but it sure is a long drive down there for me.  I'm a bit out of touch and don't know if Mitch or Doug are involved anymore.  As far as I know, John is running the show by himself (apologies if I am wrong).  Microsoft recently honored John for his efforts with NoDeNUG, among other things, by naming him a Microsoft MVP!

If you are in the area, you really should check out NoDeNUG.  Congrats to John Baird for making the groups successful.

 

Technorati Tags: ,
Wednesday, September 24, 2008 7:40:31 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Sunday, June 15, 2008

I love toys an gadgets!  They are so much fun.  Most of us geeks are gadget guys too.  I just got a GPS for my car, it's so much fun to play with.  Toys that help me get my job done faster and better are really cool.  They help me pay for the other cool toys like GPS's, HD Camcorders, MP3 players, etc.  One of my favorite toys for work is ReSharper, a super Visual Studio add-on that helps out in many ways.  If you aren't using ReSharper, you should check it out.  It isn't really a toy but it makes coding so much more enjoyable and easier, it may as well be a toy.

I've been using ReSharper for a pretty long time, I blogged about it over a year ago.  But in Oct 2007 I started my current job and switched to VS 2008 (it was beta at the time) so I couldn't use ReSharper because it didn't work with LINQ and Lambdas and all of the other cool stuff in VS 2008.  I had hoped that ReSharper 4.0 would have been ready a little sooner since the VS 2008 was officially released quite some time ago, but unfortunately I had to wait.  But now it's here and packed full of cool enhancements.

One of the best features of ReSharper is that you don't need to compile your code to see all of the errors -- not that my code has any errors ;-).   But I wrote about that and some other old features already.  Here's some new features:

  • ReSharper fully supports LINQ and the other language enhancements.
  • ReSharper provides great code completion/intellisense in aspx pages (source view)! 
  • Also, ReSharper will create method stubs from an ASPX page source view - so if I type OnCommand="foo", ReSharper can create:

protected void foo(object sender, CommandEventArgs e)
{
     throw new NotImplementedException();
}

  • With "CamelHumps", you can abbreviate class names and method names and let ReSharper complete the word.  So if I have a method named GetAllDuplicates(), I can just Type GAD!

So far, I have only one complaint but it is really no big deal.  ReSharper wants to convert a lot of my local variables to the new variant type - var.  I use the var type in code where I want it, but I don't believe it should be over used like this.  If a variable is a string and I know it is a string, it should be typed as such, as a string.  ReSharper offers the suggestion to convert it to a var.  But the cool thing about ReSharper is that I can tell it I'm not interested in this and it won't bother me any more!

Believe me, there are a ton of other great features.  Just download a trial version or ReSharper 4.0 for yourself and check it out.

 

Sunday, June 15, 2008 9:09:56 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Wednesday, January 23, 2008

We had a great Code Camp on Jan 12.  I've got a longer blog post planned to summarize the event.  I'm gonna work on that next.  But I promised Marc that I'd post his slides from his presentation "Building ASP.NET Dynamic Data Web Sites using LINQ for SQL".  And to be fair, he sent me this stuff on Jan 14 and I'm finally posting it today.  Sorry to those of you who were waiting for it.  I sat in on this presentation and it was a lot of fun and full of content.  Thanks Marc!

 

He was kind enough to create two versions of the slides:

Slide Deck for Power Point 2003 (.ppt)

Slide Deck for Power Point 2007 (.pptx)

Wednesday, January 23, 2008 9:42:21 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [3]  |  Trackback
 Monday, January 07, 2008

From now on I will take my own advice.  I spent a good part Friday afternoon and Monday morning trying to figure out what was wrong with my code and I don't want to do that again!  The problem I was having was that I had an ASP.Net control that would not postback, no matter what I tried.

I have a page with several user controls on it.  One of these user controls includes an asp:Textbox that is hooked to some JavaScript so that when the use clicks "enter" in that control a postback will occur.  The postback is accomplished by some JavaScript that calls the click event on a button that is hidden (style="display:none").  But the postback wouldn't work.  I put a few alerts in the JavaScript and I knew it was getting called, but the postback still never occurred.  The problem was not so easy to see.  That's because I had a second user control on the page.  That second user control has an asp:RequiredFieldValidator in it.  To complicate things, that validation control was tucked in a modal popup (using the Ajax Control Toolkit's Modal Popup Extender).  But, I forgot to include the ValidationGroup property on the validator.  So any control on the page would cause validation to occur which will block the postback if validation fails.  But since the validator was in the popup (which of course, was not currently popped up), I didn't see the error message that was trying to tell me there was a problem.

The problem was easily fixed (if not easily found) by simply adding the ValidationGroup property to the validator and of course, matching it up on the button that is supposed to call that validation group.  Since the hidden button on my other control was not included in the same validation group, it was free to postback any time it wants.

Monday, January 07, 2008 10:59:52 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, December 07, 2007

Yesterday at Orbius we upgraded from Visual Studio 2008 Beta 2 to RTM.  For the most part things went pretty well.  This isn't something we can do without a plan. We've been using VS2008 since May.  Our entire code base would need to migrate smoothly.  By the end of the day we were happily running VS2008 RTM! 

Things went pretty smoothly, but this was an interesting warning from the .Net Framework 3.5 installer.  It was good for a laugh and we were able to move past it.

DotNetInstallWarning

One of the guys  migrated his laptop to RTM and compiled our VS2008 solution.  There weren't too many compiler errors, although we did have some problems with some of the LINQ code our projects.  I didn't get all of the specifics, but I think it had to do with the fact that we use our DataContexts in a very disconnected way.  We get data, pass it around, modify it and eventually update the database using a different DataContext. Anyway, he came up with a work around.   There might have been some other problems but I figure if he didn't mention them, they couldn't have been too bad.  He checked the solution into SVN.

Once running the solution (web application), this was a popular message:

An item placeholder must be specified on ListView 'membersView'. Specify an item placeholder by setting a control's ID property to "itemPlaceholder". The item placeholder control must also specify runat="server".

That is because they changed the ListView (the ListView rocks, by the way) a bit.  It used to be you could put ListView content in any old Server Control.  Now it must be within an asp:PlaceHolder. It's an easy change, although we have lots of ListViews in our Solution.  Luckily, Matt on our team made all those changes. That's about it.  I don't recall too many other issues.

When I upgraded my laptop to RTM it took a while.  We followed ScottGu's advice and completely uninstalled all Beta 2 applications and components first.  I uninstalled VS2008 Beta 2 and then followed the list of programs to uninstall (the list is in the links below).  Out of about 20 items on the list, I found about 7 that I needed to manually remove.  One catch...remember to uninstall accessories first (such as ReSharper and GhostDoc), just in case.  There were a few glitches that I wouldn't expect.  Such as a warning to close an application that was blocking the install - only the blocking application was the installer itself!   Dean got a similar warning while installing the .Net Framework 3.5 on our server and he gave me the image from the top of this post.

Here are some links that may help:

Friday, December 07, 2007 7:48:14 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, December 03, 2007

I had a great time at the Central Penn .Net's Code Camp.  Judy and her team put together a great event.  I did my presentation on Creating Custom Server Controls.  The crowd out there was great.  They seemed really enthusiastic.  If you are interested in my code sample, you can get the VS 2005 solution file here (zipped).

Monday, December 03, 2007 6:38:06 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, November 20, 2007

Philly.Net's November meeting is a return to the "15 Minutes of Fame" format.  We had 10 speakers each providing a 15 minute presentation.  Sort of a geek sampler.  In addition to my duties as Swag Man (if you don't know, I gather all of the prizes), I'm doing a 15 minute presentation on LINQ. 

With 15 minutes, I'm not getting into too much detail.  Just a bunch of cool code sample to show what LINQ is capable of.  Mostly, LINQ to SQL.  If you are interested, here is the code sample solution.

If you want to learn more about LINQ, here are some site to check out:

Scott Guthrie's Blog:  http://weblogs.asp.net/scottgu/  (Of Course!)

Wes Dyer's Blog: http://blogs.msdn.com/wesdyer/  (this guy knows his stuff on LINQ!)

Check out this great video by Wes.  It explains a lot, it is definitely worth watching:  http://wm.microsoft.com/ms/msdn/visualcsharp/wes_dyer_2007_01/WesDyer_0002.wmv

LINQDemo.zip (94.67 KB)
Tuesday, November 20, 2007 5:50:50 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, November 15, 2007

I learned something new today, thought I'd share it.  Actually, I think I relearned it, it sounded familiar.  There are so many features to .Net these days it is tough to remember everything.  Anyway, here we go.

Did you know that you can put content directly inside a ContentPlaceHolder of a MasterPage?  I'm not talking about in a page's asp:Content control that matches up to the Master's asp:ContentPlaceHolder.  That is what we typically do.  But you can put content in the asp:ContentPlaceHolder control on the master.  I like to think of it as default content.  In the content page, if you put content inside the asp:Content control, it will override the "default" value from the Master.  If not, the Master's content will be shown.  Content, Content Pages, asp:Content, asp:ContentPlaceholders...confused?  Here's a simple example:

Here is some code from body of our MasterPage.  I'm only including the body to save space.  We have 2 contentplaceholders.  The first has some "default text"

<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
            By Default, show this.
        </asp:ContentPlaceHolder>
    </div>
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>

Now let's look at our first ContentPage.  It puts text in each of the Content areas:

<%@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" 
CodeBehind="WebForm1.aspx.cs" Inherits="MasterPageSample.WebForm1" 
Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    content in placeholder 1
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    content in placeholder 2
</asp:Content>

Next comes our second ContentPage.  This one only has one asp:Content control to match the second ContentPlaceHolder from the MasterPage:

<%@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" 
CodeBehind="WebForm2.aspx.cs" Inherits="MasterPageSample.WebForm2" 
Title="Untitled Page" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    content in placeholder 2
</asp:Content>

The last ContentPage has 2 asp:Content controls but only the second one has actual content. The first one is empty:

<%@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" 
CodeBehind="WebForm3.aspx.cs" Inherits="MasterPageSample.WebForm3" 
Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    content in placeholder 2
</asp:Content>

So what are the results?  The first page renders both pieces of content:

image

The second one shows it's content and since the first ContentPlaceholder wasn't matched up with a Content control, it shows the content from the MasterPage:

image

The last page has both ContentPlaceHolders matched up, only the first has no content at all.  So in this case, it overrides the "default" content from the master with nothing!  All you get is the content from the second Content control:

image

Pretty cool, huh?

Thursday, November 15, 2007 8:51:40 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [4]  |  Trackback
 Thursday, October 25, 2007

I haven't mentioned this recently, there is a NoDeNUG meeting tonight.  As one of the founders, I'm supposed to help promote the group but for some reason I forgot to mention this meeting on my blog.  What makes that even stranger is that I am the presenter tonight!  So if you are in the area, come out tonight to learn about Creating Custom Server Controls.  It's free, and we'll have pizza.

If you want to know more about these meetings, don't rely on my blogging them.  Go to NoDeNUG.org and sign up.  There's no obligation of any kind and you'll get our monthly meeting reminders via email.

Thursday, October 25, 2007 6:05:48 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, October 17, 2007

 

Tonight's meeting was sponsored by RDA Corporation.  They provided our dinner (pizza) as well as a $50 Gift Card to Circuit City as a give away!  Making it's first appearance at a Philly.Net meeting was our new coffee maker!  We bought it for Code Camp but now we'll have coffee for our regular meetings.  Enjoy it!  Thanks to Rob for running tonight's meeting.  Bill was out at Microsoft in Redmond (supposedly he's working) so Rob stepped up to run the show and make announcements.

Our next meeting is November 20th.  We are bringing back the "15 minutes of Fame" format that we used last November.  That means we'll have about 9 presenters, each doing a brief 15 minute presentation.  Last year this worked out really well and we got a great response.  If you are interested, please contact Bill or myself. 

UPDATE:  Both of the presenters are from RDA Corporation.  Check out their Technology Corner for information on these presentations and more.  Or click directly to Building an Extranet with Forms-Based Authentication using WSS 3.0/MOSS 2007 or Visual Studio 2005 Tips and Treats

Presenter:  Deepak Gupta, RDA Corporation
Topic:  Building an Extranet with Forms-Based Authentication using WSS 3.0/MOSS 2007

Sorry, I can't summarize this session.  I was busy with Philly.Net business and I missed the whole thing.  It's too bad because I was told that Deepak really knows his stuff on Sharepoint!

Presenter:  Steve Andrews, RDA Corporation
Topic:  Visual Studio 2005 Tips and Treats

Steve started by promising that these tips would be posted here on his blog.  It's a good thing too because he jumped right in with a ton of tips and I can't remember them all.  He started by showed how to customize VS menus and toolbars with a variety of features that aren't there by default.  Then he showed all kinds of shortcuts and settings that I plan on using tomorrow at work.  I've been using Visual Studio since 2002 and I didn't know many of these little tidbits.  The crowd contributed a few tips too and I'm certain that everyone learned something tonight.  As a bonus, Steve did a quick demo of Lutz Roeder's awesome Reflector tool.

We wrapped up with prizes from RDA, O'Reilly, Wrox, Sams, and SourceGear!

Wednesday, October 17, 2007 7:20:14 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Wednesday, October 03, 2007

Note:  I'm having some problems formatting the code samples inserted into this post.  I write my posts with LiveWriter.  The first few samples are inserted with a pluggin, VSPaste which always worked great for me.  But today the line breaks keep getting removed.  For the larger sample below, I tried to use another pluggin called Code Snippet.  It kept the line breaks but now my indentations are removed! What a pain.  Not sure if the problem is LiveWriter or the addins.  I'll update this when I figure it out.  Anyway...

 

Yesterday I wrote my first extension method and I thought it would make for a good post.  Ironically, yesterday ScottGu posted an extension method sample on his blog.  Are we thinking alike?  Wishful thinking by me, I guess!  Extension methods are one of the cool features you get with .Net 3.0.  You can use them to add functionality to an existing class without extending the class itself, even if the class is sealed.

Before I show my real extension method, here's a simple example for fun.  Extension methods are pretty easy to create.  This method that returns a bool if a date is my birthday:

 public static bool IsMyBirthday(this DateTime date) { if (date.Month == 9 && date.Day == 21) return true; return false; }

The unusual part is  (this DateTime date).  This parameter is the part that hooks this extension method with the Object, in this case a DateTime.  And it acts like a regular parameter because inside the method I can refer to date to get the value.

It gets called as follows:

 DateTime myDate; if (myDate.IsMyBirthday()) return true;
or even:
 if (DateTime.Now.IsMyBirthday()) return true;

The extension method automatically attaches itself to instances of DateTime!  Of course, you have to include a reference to the namespace where the method lives.

OK, how about some real code.  My TimeAgo extension method extends DateTime and returns a string that represents the DateTime compared to Now as "5 minutes ago" or "2 weeks ago", etc.  You could do a lot more with this method.  I'm not getting too carried away with the logic for what is "yesterday" or "last month" and I am not considering time zone differences.  I'm keeping it simple, hopefully you get the idea.  Here is the code and also a test console app:

namespace Utilities
{
 public static class DateExtension
 {
 public static string TimeAgo(this DateTime date)
 {
 TimeSpan timeSince = DateTime.Now.Subtract(date);
 
 if (timeSince.TotalMilliseconds < 1)
 return "not yet";
 
 if (timeSince.TotalMinutes < 1)
 return "just now";
 if (timeSince.TotalMinutes < 2)
 return "1 minute ago";
 if (timeSince.TotalMinutes < 60)
 return string.Format("{0} minutes ago", timeSince.Minutes);
 if (timeSince.TotalMinutes < 120)
 return "1 hour ago";
 if (timeSince.TotalHours < 24)
 return string.Format("{0} hours ago", timeSince.Hours);
 if (timeSince.TotalDays == 1)
 return "yesterday";
 if (timeSince.TotalDays < 7)
 return string.Format("{0} days ago", timeSince.Days);
 if (timeSince.TotalDays < 14)
 return "last week";
 if (timeSince.TotalDays < 21)
 return "2 weeks ago";
 if (timeSince.TotalDays < 28)
 return "3 weeks ago";
 if (timeSince.TotalDays < 60)
 return "last month";
 if (timeSince.TotalDays < 365)
 return string.Format("{0} months ago", Math.Round(timeSince.TotalDays / 30));
 if (timeSince.TotalDays < 730)
 return "last year";
 //last but not least...
 return string.Format("{0} years ago", Math.Round(timeSince.TotalDays / 365));
 }
 }
 class Program
 {
 static void Main(string[] args)
 {
 DateTime date;
 
 date = DateTime.Now.AddSeconds(1);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddSeconds(-5);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddMinutes(-1);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddMinutes(-5);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddMinutes(-59);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddHours(-1);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddHours(-2);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddHours(-23);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddDays(-1);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddDays(-2);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddDays(-7);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddDays(-14);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddDays(-21);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddMonths(-1);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddMonths(-11);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddYears(-1);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 date = DateTime.Now.AddYears(-2);
 Console.WriteLine(date.ToLongDateString() + " Time ago: " + date.TimeAgo());
 
 Console.Read();
 
 }
 }
 
}

 

 

Wednesday, October 03, 2007 8:46:24 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [1]  |  Trackback
 Thursday, September 06, 2007

It's been in the works for a while but now it is official.  John Baird, Mitch Ruebush, Doug White and myself have formed NoDeNUG - the Northern Delaware .Net User Group.  We've also got the support of Dani Diaz, our local Microsoft Developer Evangelist.

When:  

  • We'll meet on the last Thursday of the month at 5:30. 

Where: 

Speakers:

  • September 27 - Kevin Goff
  • October 25 - Andy Schwam
  • November 29 - Dani Diaz
  • December - We'll skip that because of the holidays.
  • January - Mitch Ruebush

Sponsors: 

More information will be coming soon. 

Thursday, September 06, 2007 7:21:22 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [2]  |  Trackback

I've got some speaking engagements coming up.  It almost sounds like an official tour is planned.

Presentation Topic: Developing Custom Controls for ASP.Net

Description:  In this demo I'll show you how to get started creating your own custom server controls for asp.net.  I'll show how to create controls, expose public properties to make them easier for other developers to implement, and handle events from the control.  We'll  create a ControlDesigner so Visual Studio can render the control at design time.  I'll even build some extra features into the control using Ajax.

Where:

I'm really excited to get out to some of these other groups for these presentations.  If you live near any of these groups, check them out.  They've all got regular, monthly meetings with great .Net content.  I've also got calls in to Madison Square Garden, LA Coliseum, Wembley Stadium and others.  But I haven't heard back from them yet.

Please, no brown M&M's.

Update:  When I get some time I'll be writing the demo out as a tutorial blog post.  In the mean time, if you are interested in the source code for this demo, here it is:

ControlsDemo.zip (1.05 MB)

Thursday, September 06, 2007 11:59:22 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [2]  |  Trackback
 Friday, August 24, 2007

I recently started playing around with WatiN (Web Application Testing in .Net) and WatiN Test Recorder.  While these are cool tools that can greatly improve the testing process, I found that there isn't a lot of information out there to help get started.  I have put together a brief tutorial on some of the basics.  I hope it helps.  I'm including code samples in this post, plus you can download the entire VS Solution and a short video below.

WatiN, pronounced "What-in", is a library that allows you to create tests for web applications.  It is based in WatiR which was created for Ruby.  Basically, you can test your web pages just like any other classes.  In my case, I'll use NUnit to control the actual tests but they are written with WatiN.  The tests run in the browser via a class named "IE".  That immediately points out one of the downsides to WatiN -- it only works with Internet Explorer.  But the tests run in a real browser so it is very accurate.

Here's a quick code sample:
            IE ie = new IE("http://localhost/somewebsite/default.aspx");
            ie.Link(Find.ById("LinkButton1")).Click();

If you run that in a test, the browser will actually open, navigate to the default page, find the LinkButton and click it.  Seems pretty simple right?  It isn't too complicated but you'll have to get used to the WatiN classes and methods.  The fact is, the tests are a pain to write.  That's where WatiN Test Recorder comes in.  All you have to do is start the recorder and the tool will begin to record your actions in the browser (there is a browser built into WatiN Test Recorder) and translate your actions into code.  If you click LinkButton1, the recorder outputs "ie.Link(Find.ById("LinkButton1")).Click();" for you!  This is a big help but it is not exactly perfect.  I have found that it doesn't get the code right and some tweaking is needed.  I'm starting to get the hang of it so the changes to the code are getting easier. 

Sample Code and Downloads:

Download my VS 2005 solution:  WatiNDemo.zip  167KB
Download my Video of WatiN Test Recorder in action:  WatiNTestRecorderDemo.avi (Right click and "save target as")  2.22MB

I created a simple data entry web application with 2 pages that pretends to register users to a web site for outdoor enthusiasts.  The first page lists the registered users, the second page is a form to register:

image image

I want to make sure my data entry page works, so I fire up WatiN Test Recorder.  The video (see the link above) shows what happens in the recorder as I step through the page  and enter the data into the web form.  Here is the code that the recorder generated for me, with line numbers added here for reference:

          1   IE ie = new IE("http://localhost:49573/RegisteredList.aspx");
          2   ie.Link(Find.ById("LinkButton1")).Click();
          3   ie.TextField(Find.ById("txtFirst")).Click();
          4   ie.TextField(Find.ById("txtLast")).Click();
          5   ie.TextField(Find.ById("txtLast")).TypeText("andy");
          6   ie.TextField(Find.ById("txtEmail")).TypeText("schwam");
          7   ie.TextField(Find.ById("txtEmail")).Click();
          8   ie.TextField(Find.ById("txtEmail")).TypeText("andy@email.com");
          9   ie.RadioButton(Find.ByName("rdoSendInfo_0") && Find.ByValue("yes")).Checked = true;
          10  ie.TableCell(Find.ByCustom("innertext", " Choose New Jersey Pennsylvania")).Click();
          11  ie.SelectList(Find.ById("ddlState")).SelectByValue("Pennsylvania");
          12  ie.SelectList(Find.ById("ddlCounty")).Click();
          13  ie.SelectList(Find.ById("lstHobbies")).Click();
          14  ie.SelectList(Find.ById("lstHobbies")).Click();
          15  ie.SelectList(Find.ById("lstHobbies")).Click();
          16  ie.SelectList(Find.ById("lstHobbies")).Click();
          17  ie.Button(Find.ById("btnSubmit")).Click();
          18  ie.Link(Find.ByUrl("javascript:__doPostBack('GridView1','Select$0')")).Click();
          19  ie.Link(Find.ById("LinkButton1")).Click();

Fixing the Generated Code:

  • Line 1 and 2 are good:  Open Internet Explorer and navigate to my page.
  • Line 3, 4, 7, and 10 are not really needed but it won't cause any trouble.  The clicks seem to be irrelevant.
  • Line 5 and 6 are just wrong.  I put the text "andy" in the textbox named txtFirst, and "schwam" in txtLast.  I can easily fix them:  
    • ie.TextField(Find.ById("txtFirst")).TypeText("andy");
    • ie.TextField(Find.ById("txtLast")).TypeText("schwam");
  • Line 9 throws this exception if you let it run: "WatiN.Core.Exceptions.ElementNotFoundException: Could not find a 'INPUT (radio)' tag containing attribute name with value 'rdoSendInfo_0'".  It should be Find.ById, not Find.ByName.  This works instead:
    • ie.RadioButton(Find.ById("rdoSendInfo_0")).Checked = true;
  • Line 11 is good
  • Line 12.  Notice no county is selected. Try this:
    • ie.SelectList(Find.ById("ddlCounty")).SelectByValue("Delaware");
  • Lines 13, 14, 15, and 16 are just clicks but nothing is selected.  Try this:
    • ie.SelectList(Find.ById("lstHobbies")).SelectByValue("Hiking");
    • ie.SelectList(Find.ById("lstHobbies")).SelectByValue("Camping");
    • ie.SelectList(Find.ById("lstHobbies")).SelectByValue("Mountain Biking");
    • ie.SelectList(Find.ById("lstHobbies")).SelectByValue("Kayaking");
  • Line 18 is correct but worth mentioning.  This selects the first row in the grid which causes the application to display the users detail in the grid.

That doesn't seem to good for a first shot!  But even with all of the mistakes, I'd rather start with the generated code then nothing at all, especially if this was a longer, more complicated test.  Plus, I admit there are features of the recorder that I am not familiar with so maybe it would work better if I actually knew what I was doing! 

AJAX Issues:

Technically, the changes I made are correct but it still won't work right.  I am using ASP.Net Ajax to call back to the server when the state (ddlState) changes.  I'm populate a list of counties (ddlCounty) on the server.  When you run the test it goes so fast that it tries to select the county before the drop down list is loaded!  I found some documentation about a WaitUntil() method but I couldn't get it to work.  So I did it the old fashioned way and put the thread to sleep:

            ie.SelectList(Find.ById("ddlState")).SelectByValue("Pennsylvania");
            System.Threading.Thread.Sleep(100);
            ie.SelectList(Find.ById("ddlCounty")).SelectByValue("Delaware");

Validation:

After the submit button is clicked, the application returns to the list of users.  Since I am writing a test, I should validate the results.  I'll add in a few asserts:

            Assert.AreEqual("Andy", ie.TextField(Find.ById("txtFirst")).Text);
            Assert.AreEqual("Schwam", ie.TextField(Find.ById("txtLast")).Text);
            Assert.AreEqual("me@email.com", ie.TextField(Find.ById("txtEmail")).Text);

The Final Test Class:

The solution contains a class library with a class Tests . Using NUnit, I can execute the test easily.

using WatiN.Core;
using NUnit.Framework;

namespace Tests
{
    [TestFixture]
    public class Tests
    {
        [Test]
        public void FirstTest()
        {
            IE ie = new IE("http://localhost/WatinDemoSite/RegisteredList.aspx");
            ie.Refresh();
            ie.Link(Find.ById("LinkButton1")).Click();
            ie.TextField(Find.ById("txtFirst")).TypeText("Andy");
            ie.TextField(Find.ById("txtLast")).TypeText("Schwam");
            ie.TextField(Find.ById("txtEmail")).TypeText("me@email.com");
            ie.RadioButton(Find.ById("rdoSendInfo_0")).Checked = true;
            ie.SelectList(Find.ById("ddlState")).SelectByValue("Pennsylvania");
            System.Threading.Thread.Sleep(100);
            ie.SelectList(Find.ById("ddlCounty")).SelectByValue("Delaware");
            ie.SelectList(Find.ById("lstHobbies")).SelectByValue("Hiking");
            ie.SelectList(Find.ById("lstHobbies")).SelectByValue("Camping");
            ie.SelectList(Find.ById("lstHobbies")).SelectByValue("Mountain Biking");
            ie.SelectList(Find.ById("lstHobbies")).SelectByValue("Kayaking");
            ie.Button(Find.ById("btnSubmit")).Click();

            //VALIDATION

            ie.Link(Find.ByUrl("javascript:__doPostBack('GridView1','Select$0')")).Click();

            Assert.AreEqual("Andy", ie.TextField(Find.ById("txtFirst")).Text);
            Assert.AreEqual("Schwam", ie.TextField(Find.ById("txtLast")).Text);
            Assert.AreEqual("me@email.com", ie.TextField(Find.ById("txtEmail")).Text);

        }
    }
}

Running The Tests:

I use ReSharper from JetBrains which makes my life easier in so many ways.  One of which is that it includes a tool to run unit tests.  The tests within the Visual Studio solution included in this post work great when run through ReSharper.  But I found that when I ran the tests with NUnit GUI directly I got an exception:

Tests.Tests.FirstTest : System.Threading.ThreadStateException : The CurrentThread needs to have it's ApartmentState set to ApartmentState.STA to be able to automate Internet Explorer.

There are some posts out there about resolving this issue but I have a better solution.  Either install ReSharper or install UnitRun, a free tool that runs tests (also from JetBrains).  While I haven't tested UnitRun, I expect it will work the same as the ReSharper solution.

Friday, August 24, 2007 11:57:43 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [12]  |  Trackback
 Thursday, August 23, 2007

It's official.  You can now register for Philly.Net Code Camp 2007.2.

On Sept. 15, 2007 we'll have 25 sessions on .Net related topics.  Check out the web site for more information including a preliminary list of topics and presenters.

Also, check out this blog post for more information on our generous corporate contributors and the prizes that we'll have.

Registration opened last night but remember, last time it filled up in less then a day!  Register now, don't get shut out.

Thursday, August 23, 2007 9:38:59 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, August 21, 2007

(Updated Sept. 5)

Philly.Net is proud to present Code Camp 2007.2 on September 15. 2007 along with our Gold Partners:

Infragistics SourceGear
Neudesic Phillydotnet_gif

Our partner organizations for this event are PhillySharePoint and PSSUG.

 

Swag/Prize contributors:

Here is a preliminary list of companies that are helping us with Code Camp:

Addison-Wesley Books, T-shirts, Canvas Bags
Apress Books, T-Shirts, etc
CoDe Magazine Magazine for each attendee*
CodeSmith Tools 5 Licenses to CodeSmith
ComponentArt Software license
Diamond Technologies Gift Card and other swag
Dundas 10 Dundas Calendar Licenses, 1 Hoodie, 1 Dundas Gauge License, etc
Google T-Shirt for each attendee*
JetBrains 5 Licenses for ReSharper
Microsoft Vista, Office, Expression Web, and other goodies
O'Reilly Books
Red-Gate an iPod and Red-Gate Software
SQL Server Magazine Subscription for each attendee!
TechSmith Snagit, Camtasia Studio, trial software, etc
Wrox Books, T-Shirts, Water Bottles
   

 

Stay tuned for more information...

 

* While supplies last

Tuesday, August 21, 2007 9:08:36 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [1]  |  Trackback

Here's a heads up on two events coming soon.  This is a great opportunity to learn about Silverlight and Expression Studio from three of the local Microsoft Developer Evangelists:  Danilo "Dani" Diaz, G. Andrew Duthie, and Zhiming "Z" Xue.  Check out the links for more information and to register.

Each event has two sessions:

  • Building Rich Interactive Applications with Microsoft Silverlight
  • Delivering Rich Web Experiences Using Microsoft Expression Studio

 

What:MSDN Roadshow
When:Friday, September 14, 2007 8:00 AM to 12:00 PM
Where:Microsoft, Pittsburgh

 

What:MSDN Roadshow
When:Thursday, October 18, 2007 8:00 AM to 12:00 PM
Where:Microsoft, Malvern
Tuesday, August 21, 2007 1:11:02 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, August 03, 2007

Here's a cool features of the .Net Framework 2.0 that I think isn't too widely known.

Did you know that you can have a public property but restrict the Set portion of it as Protected?  That gives the developer an extra level of control so that derived classes have the ability to set the property's value but other classes can only get the property's value.  Check out this sample:

    public class BaseClass
    {
        private string _myValue;

        public string MyValue
        {
            get { return _myValue; }
            //NOTE THE SET IS PROTECTED!
            protected set { _myValue = value; }
        }
    }

    public class ExtendedClass : BaseClass
    {
        public void DoSomething()
        {
            MyValue = "some value";
            string s1 = MyValue;
        }
    }
    public class DifferentClass
    {
        public void DoSomething()
        {
            BaseClass b = new BaseClass();
            string s = b.MyValue;
            b.MyValue = "some value";  //THIS GETS A COMPILER ERROR!
        }
    }

You can see that in ExtendedClass I can use the property to GET or SET, but in DifferentClass I can only GET.

Here is the error that Visual Studio reports:

PropertyError

 

I should mention that Intellisense did not show this error (with the squiggly lines) instantly as it usually does.  I needed to compile the project before Visual Studio recognized something was wrong.  And in case you are wondering...Yes, this feature is included in VB.Net too.  Although I should mention that in VB.Net, Intellisense showed me the error even before I compiled.  Darn, I hate to say nice things about VB.Net.  Here is a VB.Net version:

 
Public Class BaseClass
    Private _myValue As String

    Public Property MyValue() As String
        Get
            Return _myValue
        End Get
        Protected Set(ByVal Value As String)
            _myValue = Value
        End Set
    End Property
End Class
Public Class ExtendedClass
    Inherits BaseClass

    Sub DoSomething()
        Dim s1 = MyValue  'GET WORKS
        MyValue = "Some Value" 'SET WORKS
    End Sub

End Class
Public Class DifferentClass
    Sub DoSomething()
        Dim b As New BaseClass
        Dim s1 As String
        s1 = b.MyValue  'GET WORKS
        b.MyValue = "Some Value" 'SET GETS A COMPILER ERROR!!!!
    End Sub

End Class

Hopefully this is helpful to you!

Friday, August 03, 2007 8:33:37 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [1]  |  Trackback
 Wednesday, July 18, 2007

Once again we had a great turnout for the meeting...over 90 people!  This week we had three presentations on a variety of topics.  Incidentally, the first two presentations use XAML... time to start learning something new!

 

Presenter:  Aaron Shafer, Lockheed Martin

Topic:  Silverlight

Aaron started of with some background on Silverlight (formerly known as WPF/E).  Silverlight is a subset of WPF (Windows Presentation Foundation) meant for use on the web.  Silverlight provides a means to create some slick websites based on XAML.  It offers some great and easy to use audio and video features so you can enable your sites for media. 

Before long Aaron was into the demos and we had "Hello World".  Pretty quickly he got into some cooler stuff with animation.  And with a bit of code he wrote an web application that allows users to drag a shape around the page.  One of the coolest aspects of this is that he ran his demos in IE and Firefox, and then he ran them on a Mac!   That makes Silverlight a pretty powerful tool!

 

Aaron recommends checking out Tim Sneath's blog as a good source of information.  Also check out the Silverlight.Net site and of course Scott Guthrie's blog.

 

Presenter:  Bill Wolff, Agility Systems

Topic:  Acropolis Introduction

Bill started off with a disclaimer: He learned just enough about Acropolis to do this demo.  He learned about it at Tech Ed and then he went to the Acropolis site and watched some videos.  You'll need VS Orcas to do any of this stuff.  Acropolis is a design tool allowing developers to easily create windows applications.  It will create an MVC (Model View Controller) style application for you, storing the presentation layer in XAML.   He showed us a pretty cool demo that created a multi-document interface "Notepad" application.  XAML has a document management template that gets you started and puts in a lot of the features you'll need.  Bill showed a bunch of cool demos.  Download the source code from the Acropolis site and check it out for yourself.  My advice, I'd do it on a Virtual Machine!  None of this stuff is production ready.

 

This is cool stuff and was a first look at this technology for most people in the room. 

The Acropolis site has everything you need including the download, samples, videos and documentation.

 

Presenter:  Rob Keiser, Row-5

Topic:  PowerShell for .Net Developers

I've heard PowerShell defined as "command line on steroids".  The difference is that PowerShell works with objects, the .Net Framework, SQL and more.  There are lots of commands that are keyed in to execute them,  but there are a lot of aliases (shortcuts or abbreviations) too.  A lot of the commands are similar to Unix commands, so if you are used to that, you'll be all set.  Plus, the "|" (pipe) symbol is back and you'll use it a lot.  The power of PowerShell is not the simple commands that you can execute, but the ability to create scripts.   He showed a cool, simple demo of how to use PowerShell to browse through your registry.  Next he browsed through hard drives using the "get-wmiobject" command.  Next Rob got into using PowerShell with .Net.  He easily created a dataset.  And he browsed through SQL Server information using SMO (Server Management Objects) and even took his databases offline.  Lastly, he demo'd PowerGadgets, an extension to PowerShell.  WithPowerGadgets you can easily graphically chart output from PowerShell.

 

The fact is, none of this stuff is glamorous, but Powershell has some cool functionality that, in many circumstances, could make our jobs a lot easier. 

 

 

To get Powershell, download it here.

 

 

Meeting Sponsor: Solvepoint... Thanks for the sandwiches!  

Additional Door Prizes courtesy of:  

Wednesday, July 18, 2007 7:45:10 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback

Around the country various technical communities have been holding "Geek Dinners".  The guys in Northern NJ have been doing them for a while now.  The idea is simple, a bunch of us get together and have dinner.  Everyone pays their own way and it's a chance to hang out with other members of the local .Net community.  Steve wants to get the ball rolling in the Philadelphia area so check out his blog for more info.

Wednesday, July 18, 2007 6:14:45 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, July 10, 2007

Regional .Net User Group Leadership Meetings

Two weeks ago Bill hosted a Philly.Net Leadership meeting at his house.  He also invited the leadership of PSSUG (Philadelphia SQL Server User Group).  We tossed around a bunch of ideas for how we may better serve the community.  In addition, yesterday was the monthly regional Community Leadership conference call hosted by our D.E (Microsoft Developer Evangelist), Dani Diaz.  Again, we discussed ways to best server the community.  Dani's conference call continues the tradition started by Peter Laudati (who filled in when we had no D.E.).  This call typically includes community leaders from Philly.NetCentral Penn .Net (Harrisburg area),  Lehigh Valley .Net, .Net Valley (Scranton area), the new Delaware .Net, and others.  I'll give you the gist of these meetings, mostly from the Philly.Net perspective.

In both of these meetings, there seemed to be two main topics:  Meetings and Communications.  Regarding meetings, we discussed various ideas for different types of Philly.Net meetings including the following:

  • Monthly Meetings:  Our monthly meetings are well attended and very successful.  Still, we want to include a variety of topics and make sure we cover a wide variety of material from beginner to expert.
  • South Jersey and Center City:  These meetings started off strong but we have don't have venues to host these meetings.  If you have any ideas, please contact me or Travis (for NJ) or of course, Bill.
  • Study Groups:  In the past, Rob Keiser lead a certification study group.  We are looking to restart that group.
  • Code Camp:  Our Code Camps continue to be very successful.  We want to host even more of them!  In addition, there are some other ideas going around such as hosting similar types of meetings focusing on Interop, Gaming, and more!  I'll keep you posted.

In the area of Communication, we are trying to figure out the best way to get the information out to our members.  As we grow, there will be a lot of information.  How would you want to get it?  Some people read blogs daily, others want to get monthly newsletters.  And others don't want any more email at all!  I like the idea of using a blog to get out information as it comes in, in short to medium sized posts, like this one.  People that read the blog get the up to date information.  Then, once a month, we could repeat the information in a newsletter, possibly included in our typical monthly meeting announcement.  We'll certainly want feedback from the community on this topic.  Let me know or speak up at a meeting with your ideas and suggestions.

Upcoming Events: 

I'll try to keep everyone alert regarding user group meetings in our area.  I'll include all the meetings I know about including various Pennsylvania .Net groups, PSSUG, and The Philadelphia Area Sharepoint User Group

Philly.Net South Jersey meeting:  In August Philly.Net plan to team up with PSSUG (Philadelphia SQL Server User Group) to host a meeting in South Jersey.  We figure that most .Net developer's need to work with SQL Server so why not team up with these guys!   Keep an eye on the Philly.Net site and the PSSUG site for more details.

Delaware Meeting:  Doug White is trying to get the Delaware .Net community going strong.  Did you know he's already had a bunch of meetings?  Stay tuned for more information regarding Delaware meetings in the Newark/Willmington area. 

Tuesday, July 10, 2007 7:57:35 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, June 20, 2007

phillydotnetPerficient sponsored the monthly Philly.Net meeting featuring presentations on SQL Server Integration Services and Sharepoint. 

Don't miss our next meeting:  July 18th at Microsoft in Malvern.  This meeting is sponsored by Solvepoint.  The speakers and topics haven't been announced yet, stay tuned for more information.  And keep an eye on this blog for more information about Philly.Net Code Camp 2007.2 scheduled for September.

As always, here is my synopsis of the meeting.  If you miss a meeting or want some information about something you've seen at Philly.Net, hopefully you'll find the answer in my synopsis.  I try to put in links and information that the presenters think are useful.  Click on Philly.Net in the category cloud to see all Philly.Net related content (or click here).

 

Presenter:  Tony Testa, Perficient

Topic:  SQL Integration Services

Tony started off with a quick intro to SQL Server Integration Services (SSIS), the next generation of SQL Server DTS (Data Transformation Services from SQL Server 2000).  SSIS has many uses but it is well suited for the ETL process.  Improvements over DTS include many new features, logging, configuration, debugging, an API, better deployment, and more.  He quickly jumped into a quick demo showing an SSIS package with a For Each Container using a Script Task - with debugging too!  With these simple demos you can easily see the power of SSIS.  He continued on to demonstrate many other cool features in SSIS.  He wrapped up showing us several different ways to execute a DTS package including from SQL Server, from the File System, and from a .Net application.

Here are the files from Tony's presentation:  SSIS_Demos.zip (522.14 KB)

 

Presenter:  Afshin Zavareh, Perficient

Topic:  Sharepoint 2007 Features and Components

Afshin started off good.  I always like a presentation that starts with "I only have one slide"!  The one slide was a good introduction to the various Sharepoint Feature Areas.  He quickly moved on to the demos.  One interesting point he brought up... all of the information for the Sharepoint demo site he created is stored in SQL Server.  There are no actual aspx files.  Sharepoint provides so many cool features that you can easily add into a site.  Here are some of the features Afshin showed us:

  • Using templates to create sites
  • Implement RSS
  • Use built in search - not only for pages but other content like word docs.
  • Create a custom search results page using web parts.
  • Using Site Master Page settings to define the look of the site.
  • Workflow for approvals.
  • Using business forms.
  • and more...

This is a big topic and Afshin did a great job at showing us the basics to many features.  He sent me a nice list of Sharepoint blogs that should be helpful to people who want more information:

 

Meeting Sponsor: Perficient... Thanks for the Pizza!

Additional Door Prizes courtesy of:  Microsoft and Wrox Publishing.

Wednesday, June 20, 2007 6:09:58 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, May 23, 2007

The reviews are in… Philly.Net Code Camp 2007.1 was a huge success!


Thanks to the hard work of an excellent group of presenters, Philly.Net hosted a great Code Camp on Saturday, May 19th.  Did you attend a session and want more information?  Did you miss Code Camp and want to find out more about it?  Included here is a bunch of information to help you out.  Read on to see Philly.Net Code Camp feedback, presenter info (blog, web and email addresses) and prize contributor information.

Thanks to Bill Wolff for organizing the event and running Philly.Net all year round, and everyone else who worked hard to make the day great.

-Andy "The Swagman" Schwam


Your Feedback:

Here are some of the general comments from Saturday.  I know that many of the presenters look forward to seeing what you write.  They love the compliments and use your suggestions to enhance their future presentations.  Remember that the presenters don’t get paid and put a lot of time into getting ready for these sessions.  As one of the organizers, I like to see the comments so we know if we are on the right track.  We also get tips for improvement.  Here are some of the general comments about Code Camp. 

“Lots of good info in a short time. Helps me flatten out the learning curve.”

“I really appreciate you conducting this camp with no cost to attendees”

“No Coffee”

“Please have more code camps. It’s excellent and only way to keep up with technology for me”

“Very well organized session…thanks for everything…Appreciate much for all the organizers, sponsors and speakers”

“Have evaluations forms ready before fist session”

“ It is very beneficial to the group + it would be difficult to complain about a no-cost event”

“ I really feel more motivated to go deeper into Microsoft technologies. See you in the next code camp”

“I found all session extremely valuable”

“First time in code camp and like the way it’s conducted. Liked the flexible way of attending various session as I like. Thanks for material and food”

“The material was very informative and the speakers were entertaining. You could really tell that they have used these technologies in the real world”

“Learned a lot of new stuff…will apply to the work I do”

“This event was everything that I had hoped for. A good introduction to .Net 3.0”


Links for presenters, etc:

If you need some more information about one of the sessions you attended, hopefully one of the links or email addresses below will help.  By the way, to prevent spam, I modified the email addresses.  I'm sure you can figure out the translation!

Jean Barmash:
Here is the address for my blog – I already posted the slides for my talks there - http://home.infusionblogs.com/jbarmash/default.aspx
My company’s website is www.infusion.com.

Russ Basiura:
Russ Basiura  is the president of the Philadelphia Area SharePoint User Group (http://www.PhillySharePoint.org).  He specializes in helping companies in the Philadelphia area deploy SharePoint.  If you have questions about SharePoint or would like to discuss a specific project, he can be reached at russ AT rjbtech DOT com or call 215-699-2780 x101.  His website is http://www.SharePointSpecialists.com.

Sam Batterman:
email:  samb AT microsoft DOT com
blog: http://sambbiblog.spaces.live.com

Sharon Dooley:
For more information, contact Sharon at:  sharond AT voicenet DOT com.

Sam Gentile:
http://codebetter.com/blogs/sam.gentile (blog)
http://samgentile.com (home)
managedcode44 AT hotmail DOT com (email)

Kevin Goff:
www.commongroundsolutions.net   (main site)
www.TheBakersDozen.net   (blog)
kgoff AT commongroundsolutions DOT net  (email)

Travis Laborde:
http://www.datadeluxe.com/ - Under "News" you can see links to the talks I've done along with links to every item covered in the talks.
http://clipmarks.com/clipper/travislaborde/ - My Clipmarks blog.  To see new stuff as I post it of course.  Some items came up in class that I said I'd blog about, and this is where they'd see it.

David Laribee:
http://laribee.com/blog/ (Blog)
laribee AT gmail DOT com (Email)

Mark Magliocco:
http://www.markm.com/markm/code_camp_2007_0519/Mark_magliocco_2007_code_camp_presentation.htm
http://www.markm.com/markm/code_camp_2007_0519/RSS_BASICS.pdf

Blog: www.markm.com

RSS ( Really Simple Syndication ) is on of the hottest areas of web 2.0.  When the Blogosphere emerged, RSS feeds really took off.  It is a must know technology, and an essential element of your web applications as well as search engine marketing. We will review the basics, what are the elements and tags.

If your name/information isn't listed here, please send it to me, I'll be sure to update the copy of this information on my blog.


Code Camp Contributors:

I’d like to thank all of the companies that contributed prizes.  Yes, Code Camp is completely free.  So you may be wondering, who paid for breakfast, lunch, and all of the prizes?  Many companies stepped up and supported this event.  I hope you will check out their websites and give their products a try! Thanks to the generosity of these companies, we had enough "swag" to have give-aways during every session!

 

Company Contribution
Microsoft Microsoft let us use the Malvern, PA office for Code Camp!  They also donated several prizes including:  1 Zune, 1 Vista Ultimate, 3 Vista Business, 2 Expression Web
Perficient Perficient provided our breakfast.  A great way to start the day!
RDA RDA provided our lunch, not too mention some cool beach balls!
Advisor Advisor provided Sharepoint Advisor which was included in each attendee gift bag.
Apress Apress provided us with a bunch of books as well as some note pads.
Sams/Addison Wesley Sams/Addison Wesley sent us lots of cool stuff:  Books, t-shirts, bags, pens, quick reference cards, etc.
Cizer Cizer provided something for each attendee:  A license for Cizer's Drop In Reporting.
Code Magazine Code Magazine sent us a copy for each attendee's gift bag.
ComponentArt Component Art provided 1 license to WebUI for ASP.Net.
Diamond Technologies Diamond provided travel mugs for each attendee gift bag.  They also gave us $25 gift card to Circuit City for the raffle.
Dundas Dundas sent us a license for Dundas Gauge, 20 licenses for Dundas Calendar for RS, a Dundas Software hoodie and other swag (pens, bags) .
Google Google sent us a bunch of T-Shirts for the raffle.
JetBrains Jet Brains donated 5 Personal Licenses to the popular ReSharper tool.
O'Reilly O'Reilly send us a bunch of books.  They were distributed in sessions and during the end of day raffle.
Red-Gate Red-Gate provided a copy of the brand new version of ANTS Profiler and two copies of SQL Refactor.  In addition, they sent us pens, t-shirts, memory sticks, etc. 
Wrox Wrox sent us a 50 books!  They also provided T-Shirts.

Wednesday, May 23, 2007 1:55:43 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, May 07, 2007

Tech-Ed is coming up quickly.  I've been looking at the session catalog on line.  There is going to be a lot of great content and I am already trying to figure out how my time will be best spent.  Jeff just got back from Mix07 and he is really excited about the demo's/presentations that he saw.  I asked him about his favorites figuring they might do some repeats at Tech Ed.  Check out his thoughts.  The cool thing is that we don't need to wait until Tech-Ed to hear the presentations.  Just go to the sessions page on the Mix07 site and listen to the presentations over the web!  It even uses Silverlight to stream the media!

Updating this post: Scott Guthrie has a great post today where he explains some of the technology discussed at MIX07.  He also recommends several sessions for us to watch over the web.

Monday, May 07, 2007 7:40:25 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, April 26, 2007

Sold Out

If you haven't registered yet for Philly.Net's Code Camp 2007.1 you are out of luck.  This event is full!  I am not surprised it didn't take long for registration to fill up, there is a great list of presentations

A swag mans job is never done!

For those of you who are registered, you'll be glad to know that I've been working hard to make sure we have lots of door prizes.  Many companies have been very generous with prizes for this event.  It is really awesome that we have their support.  Here is a sneak peek at some of the companies and prizes we'll have.  This list is unofficial and will change.  Hopefully I'll be adding more.  If you have any ideas for swag, please contact me.  I'll try to keep this list updated as things change.

 

*Updated on 5/26

Contributor Contribution
Microsoft 1 Zune, 1 license Office, 1 license Vista, & 1 license Expression Web
New Horizons Learning Centers Breakfast
RDA Consultants Lunch
Apress Books
Cizer 1 Full License for Drop In Reporting for every attendee!
Component Art 1 Web.UI for ASP.NET Subscription License
Diamond Technologies $25 gift card, Memory Sticks and other swag
Dundas 1 Dundas Gauge, several licenses for Dundas Calendar for RS, a Dundas Software hoodie and other swag (pens, bags)
Google T-Shirts
JetBrains/ReSharper 5 personal licenses for ReSharper
O'Reilly 10 Books
Red-Gate Software A copy of the brand new version of ANTS Profiler and two copies of SQL Refactor.  Plus pens, t-shirts, memory sticks, etc.
Sams/Addison-Wesley Books, t-shirts, bags, pens, quick reference cards.
WROX 50 Wrox books, t-shirts
Thursday, April 26, 2007 12:13:18 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [1]  |  Trackback
 Wednesday, April 25, 2007

A few friends have asked lately about pasting code into blog posts from visual studio.  When you do add code, you want to retain the syntax highlighting features from VS so the code is more readable.  This is a snap with Windows Live Writer.  Live Writer is still considered Beta software but it seems to work pretty well for me.

All you need to do is go to the Live Writer Gallery and check out the cool pluggins that are available.  In this case, I am using the pluggin called "Paste From Visual Studio".

Just install that and in a snap you go from this:

 

public void dosomething(string anArgument)
{
//this method doesn't really do anything.
string message = "hello world"
DateTime date = DateTime.Now;
}

To This:

    public void dosomething(string anArgument)
    {
        //this method doesn't really do anything.
        string message = "hello world";
        DateTime date = DateTime.Now;
    }

It couldn't be easier!  Now I just need to add some posts to this blog that really use some pasted code!  Check out this other post I wrote about some other cool features of Live Writer.

 |  | 
Wednesday, April 25, 2007 7:48:47 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, April 20, 2007

Philly.Net is hosting Code Camp on May 19th.  Registration is now open!  This event will most likely "sell out" so register here  now before it is too late.  This is a FULL DAY, FREE event!

Bill has already arranged a great group of speakers with a wide variety presentation topics.  While they are subject to change, here is the list of topics. 

ASP.Net/Sharepoint

  • Internet MOSS
  • InfoPath
  • AJAX
  • Dev Testing
  • Sharepoint Workflows
  • Content Types

.NET 3.0/Orcas

  • WCF Intro
  • XAML, Silverlight
  • WF
  • WCF
  • LINQ
  • SOA/WCF

Coders

  • Framework Development
  • Enterprise Library
  • Unit Testing
  • Aspect Programming
  • NHibernate
  • CAB/Validation

SQL

  • MDX
  • Data Mining
  • DataFlows
  • Schedule Performance
  • TSQL
  • SSIS Scripts 

Utilities

  • RSS
  • XNA
  • Tools
  • Powershell
  • Licensing
  • Compact Framework

Sponsors:  In addition to all of the knowledge you will get, there is free food too!  Morning refreshments are provided courtesy of New Horizons Learning Centers. Lunch is sponsored by RDA Consultants.

Door Prizes/ Raffles (aka swag)  But wait, there is more!  We'll have lot's of prizes to give away at the end of the day.  This is my department (they call me the "swag man")!  I am currently working on getting door prizes from as many companies as possible.  If you would like to provide a door prize of any kind, contact me!  This is a great opportunity for any company to reach a great target audience: .Net developers in the Philadelphia area.  We've already got some great stuff to give away and looking for more.  Can you provide software,  books, hat, shirts, gift certificates, travel mugs, thumb drives, or anything else that would make a cool door prize?  Please contact me for more information.

Friday, April 20, 2007 1:29:10 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, April 19, 2007

 We were back again at SEI in Oaks, PA for another great Philly.Net meeting. 

 mark your calendars for the following upcoming events:

Wednesday May 16:  Philly.Net Pub night. Marc Ziss has set up the second pub night at the Great American Pub in Conshohocken.  Once again, Human Capital Management is coming through to sponsor the night.  Last time was a lot of fun.  Don't miss this chance to have a beer or two with other members of Philly.Net.  No topics, no presentations.

Saturday May 19:  Code Camp is back!  Code Camp is a great way to learn a lot.  A whole day (8:30-5:30) including about 30 sessions on a variety of topics.  Bill is taking volunteers now for speakers.  Don't miss this...you can't beat this free event!

 

My Disclaimer:  The following is my summary of the presentations from the evening.  Hopefully I got the facts right.  I've included as many links to the topics as possible.  Check out the presenters blogs and websites for the most accurate information.  I'm happy to correct any mistakes. 

Note:  I'll add the slides and content to this post as soon as I get them from the presenters.

 

Presenter:  Peter Laudati, Microsoft

Topic:  Windows CardSpace

Peter Laudati is the NY/NJ Developer Evangelist.  Since that job has been a vacant in the Philadelphia market for a while, Pete has been helping us out and supporting our user group.  Check out his blog for lots of information including postings about Microsoft events in the NY/NJ/PA area.  Pete started off with a quick overview of the different pieces of the .Net Framework 3.0CardSpace, formerly known as InfoCard, is one of those pieces.  To get the 3.0 Framework, you can download it from MSDN and run it on Windows XP or 2003.  But if you have Vista, it is already included.  CardSpace is part of a system that provides a digital identity designed to solve authentication issues that users experience.  It is meant to solve security issues on the internet such as phishing, fraud, password fatigue, and the multitude of authentication systems we must use.  Microsoft worked with several partners to create this system and they developed the Laws of Identity.  You can learn more about the that at:  www.identityblog.com.  Some of the key features they planned included consistent experience across contexts, it should be available on multiple platforms, and should have minimal disclosure for a defined use.  CardSpace is the client side identity selector piece that is implemented within applications.  The system includes self-issued (you create them yourself) and managed cards (such as credentials issued by a bank).

He showed a demo using CardSpace to login to the website www.sandbox.netfx3.com.  He also showed us an example in code of how to implement CardSpace.  Since there are only 4 key tasks to complete, implementation doesn't look too difficult.  Peter also brought some great prizes to include in our raffle...Thanks Pete!

 

 

Presenter:  Robert Green, MCW Technologies

Topic: Using Windows Workflow Foundation to Build an Order Processing System

Rob started out with a little background.  He has two blogs.  The code samples will be on this blog but his more active blog is here.  He started out giving us the basics of Workflow Foundation.  After a few minutes he left the slides and jumped right into Visual Studio.  That's a good presentation from my perspective!   In VS2005 he started dragging workflow items out of the toolbox, wrote a little code (yes, "Hello World") , and showed just how quickly you can create a simple workflow.  He then explained the difference between a Sequential Workflow (basically, the steps all occur sequentially) and State Machine Workflow (the workflow does something, saves its state, and then waits for something else, maybe an external event, to happen).  He then walked us through a more complex example with a State Machine workflow.  This was a pretty complex sample with several steps and events.  But in spite of its complexity, Rob made it seem pretty easy to accomplish.  He summarized with his thoughts on the current State of Workflow.  To paraphrase, he really likes workflow but the tools through Visual Studio need some work but he is hopeful that it will all be resolved with the next version of VS code named "Orcas".

 

Meeting Sponsor: 

   Provided excellent hoagies!  

Additional Door Prizes courtesy of:  ,    and Microsoft

Thursday, April 19, 2007 7:21:16 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, April 11, 2007
Philly.Net hosted its second Center City meeting on April 11 at Structured Hosting. Just like the last meeting in NJ, we had a capacity crowd again. I think these new meetings/venues are a success! If you missed the meeting (or if you need some details) here is my synopsis.
Wednesday, April 11, 2007 9:26:53 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [1]  |  Trackback
 Friday, March 30, 2007

Meeting Date: March 29, 2007

Philly.Net has expanded.  We now host meetings in the Philly Suburbs,  Philadelphia (Center City), and now...South Jersey.  Thanks to Travis Laborde for getting the new South Jersey branch going.  Tonight's meeting was a huge success.  It was standing room only with about 50 attendees which is pretty impressive for a first meeting.  Pizza and location provide by New Horizons Training Center.  Plus, Travis' wife Jessica treated us to a cake to celebrate the start of Philly.Net in NJ.  It was a great meeting.  Please read on...

Presenter:  Travis Laborde, Data Deluxe

Topic:  Developer Testing

Not only did we learn a lot from Travis' presentation but we laughed a lot too.  Travis always does a great job to make sure his presentations are fun.  Tonight he talked all about developer testing.  And typically for Travis, he included bunch of great tools.  He demo'd the basics of NUnit, a FREE tool that assists with executing test classes.  He also showed MBUnit which he dubbed "NUnit on steroids".  This tool allows you to execute similar tests as NUnit, but introduces the RowTest attribute so you can run the same test in multiple iterations, passing in different parameters each time.  Next he went through testing for "Code Coverage" via TestDriven.Net and NCover.  He ended up with some quick demos of SeleniumIDE, a very cool FireFox add-on that allows you to record steps in the Browser so you can play them back.  This gives you the ability to test an ASP.Net UI over and over again automatically.

If you are into free tools and tips for .Net development, check out Travis' clipmarks site where you can read about all kinds of cool stuff.

 

 

Presenter:  Scott Watermasysk, Telligent Systems

Topic:  ASP.NET Tips & Tricks

Scott has been posting ASP.Net tips and tricks on his blog for a while.  Tonight he went through a bunch of them for us.

It is hard to summarize Scott's talk because he talked about so many items.  The good news is that most of the content is up on the web, check out the links included in my text. He provided us with a ton of tips for everyday use.  Some tips provided for controls:  Try to use <asp:Literal> control instead of <asp:label> and use <asp:Repeater> instead of <asp:GridView> where possible.  Some general ASP.Net tips included:  use Page.IsValid from button event handlers, use the AppOffline.htm page when you are doing "construction", use the new VirtualPath class to convert relative paths to absolute ones.  And Scott also spent a lot of time talking about State Management and Caching tips.  He also recommended a few articles:  one by Fritz Onion on Control State and "A Matter of Context" by Susan Warren.  I'll update this blog post and include his slides as soon as I can.

As a special bonus, Scott provided free copies of CodeSmith Professional for all attendees.  This certainly went over big with the crowd.

 

Meeting Sponsor:    

Additional Door Prizes courtesy of:  and Microsoft

Friday, March 30, 2007 6:57:57 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, March 29, 2007

I'm a big fan of anything that makes my daily grind easier.  Some time ago I was turned on to a cool VS2005 add-in for C#/ASP.Net developers:  ReSharper.  There are so many great features packed in to this tool.  Check out the complete list of features on the JetBrains site.

Here are a couple of the features that stand out to me:

Quick Fixes - When ReSharper detects a problem in your code, it suggests a solution.

Status Indicator and Marker Bar - ReSharper keeps track of whether or not your code will compile and reports the answer with the Status Indicator located at the top of the Marker Bar.  Within the Marker Bar are color coded stripes that link to all of the errors or warnings ReSharper finds in your code.

Refactoring - ReSharper includes a list of cool refactoring functions to help the coding process.

Navigation and Search- Ctrl-Click any symbol in your code to go to its definition.  Or Alt-F7 to find all usages of a variable.

Unit Testing and NUnit integration - If your project includes NUnit tests, ReSharper will put some icons in the left gutter of the VS editor.  Clicking on these icons will give a few options to run the tests.

Using Directives - ReSharper tells you when you need to add a using directive.  It also tells you when you can remove using directives that you included but no longer need.

Many, Many More - I could go on and on here.  There are so many great features.  I don't know how I ever worked without this.  Check it out for yourself.  Then convince your boss to buy it for you.  But it isn't too expensive.

Thursday, March 29, 2007 7:14:30 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Thursday, March 22, 2007

It is official.  I am registered for Microsoft Tech Ed.  If you are planning to go, I suggest signing up fast.  Many of the hotels that offer Tech-Ed pricing are sold out.

See you in Orlando in June,

Andy

Thursday, March 22, 2007 7:37:40 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Wednesday, March 21, 2007
We had a another great Philly.Net meeting on March 21, 2007, packing several great speakers into one night.
Wednesday, March 21, 2007 7:11:09 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
Philly.Net is expanding to include .Net Developer Usergroup meetings in South Jersey.
Wednesday, March 21, 2007 6:24:22 PM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, March 20, 2007

I just checked the Tech-Ed 2007 site and I noticed that the session catalog is up.  I'd expect changes since Tech-Ed is not until June.  But it is nice to see what is planned so far.

Tuesday, March 20, 2007 8:53:58 AM (Eastern Standard Time, UTC-05:00)  #    Disclaimer  |  Comments [0]  |  Trackback