So, I was just talking to one of my coworkers over IM and we were discussing WCF. During the conversation I said:
Josh Heyse: programming WCF for 90% of developers is just interfaces and classes marked with ServiceContract and DataContract
Josh Heyse: the rest is in the configuration
Josh Heyse: and if you're a huge nerd you'll get that pun
Made me smile and figured others might enjoy it as well. :)
I'll be presenting at the Visual Studio Team System User Group next month on the features Visual Studio Database Edition provides and how it makes developers more productive. Recently Microsoft announced it would combine VSTS Database and VSTS Developer since most developers also interact with the Database. I think this is an extremely smart move on their part because it allows developers to build databases better. I will be presenting at the Chicago Loop meeting and Paul Hacker will be presenting in Downers Grove.
Official Announcement
On September 29, 2008, Microsoft announced that Visual Studio Team System Development Edition will be combined with the Visual Studio Team System Database Edition in Visual Studio Team System 2010. Microsoft recognized that many developers write front end code in addition to working deeply with database code and database tables. Bringing the feature of Team Development Edition and Team Database Edition together sets together enables you to take advantage of the core tools for application development as well as the necessary tools for database development, including performance profiling, code analysis, code metrics, code coverage, database refactoring, Schema Compare, Data Compare, and more. You may also be happy to know there is a way to take advantage of this 2 for 1 deal TODAY. Really, no joke!
Want to hear more about it? Maybe even see these two incredibly powerful tools together? Join the Chicago Visual Studio Team System User Group to hear more about how to get your hands on this awesome duo of tools, talk to field experts about how these tools have improved their overall quality of life (OK, maybe just their work environment), and to see them in action!. We have decided to hold this session in both the Chicago Loop and Downers Grove offices to ensure everyone has a chance to learn about this terrific new opportunity.
To sign up, please email Laskowski.Dave@gmail.com. Please indicate which meeting you plan to attend.
Meeting Agenda
5:30pm – Pizza
6:00pm – Introductions
6:15pm – Presentation and Demo
7:30pm – Q&A and Raffle
Chicago Loop Meeting Details:
Wednesday November 5th, 2008
77 West Wacker Drive, 23rd Floor, Chicago, IL
Map
Downers Grove Meeting Details:
Wednesday October 29th, 2008
3025 Highland Parkway, 3rd Floor, Downers Grove IL
Map
Speaker Bios:
(Downers Grove)
Paul Hacker is a Principle Consultant at Polaris Solutions, LLC in Indianapolis, with a passion for Team System. He has been working with the product since beta 3. Paul has implemented Team System/TFS in numerous organizations. When not spending time with his family, you can find him presiding over the Indianapolis TFS SIG, Podcasting on Radio TFS or writing tools to enhance Team System. You can reach Paul at paul.hacker@polarissolutions.com
(Chicago Loop)
Josh Heyse is a Senior Solution Architect with Catalyst Software Solutions. He has always focused on staying ahead of the technology curve, investigating Microsoft technologies before they are available to the general public. Josh began developing on beta versions the .NET Framework when they were released in early 2001. Josh is currently focused on WPF, LINQ, and most recently Silverlight 2.0. As an architect Josh spends a lot of time improving the software development lifecycle by implementing pattern & practices, continuous integration and ALM tools such as Team Foundation Server. MCSD, MCDBA, MCPD
I'm pretty happy with the number of people who have been downloading and trying out Dynamic Data Filtering. On average there are about 20 downloads a day with around 50 page views. There has been a lot of good feedback on both the ASP.NET forums and on the CodePlex project site 5over the last week or so. So much actually that I am having trouble keeping up with answering the questions coming in.
One question did catch my eye though. It was a member of the ASP.NET forum asking about being able to search on all of the columns within a given table. [View the Post] Dynamic Data doesn't support this functionality out of the box, but it is flexible enough to write something yourself to do it. The main things that makes this possible is that a single FilterTemplate can return one ore more DynamicFilterParameters which produce lambda predicates.
In this case, you can accomplish this logic of searching multiple columns in a table by saying where ProductName LIKE [Value] or ProductNumber LIKE [Value] etc... To accomplish this in Dynamic Data Filtering you would utilize the OrExpressionParameter to create a collection of LikeExpressionParameters to do the predicate for each individual column.
I spent a little time creating a simple example which performs this logic. I also implemented a Columns property which allows you to specify using a comma separated list the columns you want searched. If Columns is left null or empty all columns are searched. The aspx for the user control only contains a single asp:TextBox with the Id=TextBox1.
public partial class TableTextSearch : Catalyst.Web.DynamicData.FilterTemplateUserControlBase
{
public string Columns { get; set; }
private MetaTable Table
{
get
{
IDynamicDataSource source = this.FindDataSourceControl();
if (source != null)
return source.GetTable();
return null;
}
}
public override IEnumerable<Parameter> GetWhereParameters(System.Web.DynamicData.IDynamicDataSource dataSource)
{
OrExpressionParameter parameter = new OrExpressionParameter();
string[] cols = null;
if (!string.IsNullOrEmpty(Columns))
{
cols = Columns.Split(',');
for (int i = 0; i < cols.Length; i++)
cols
= cols
.Trim().ToUpper();
}
var columns = (from c in Table.Columns
where cols == null || cols.Length == 0 || cols.Contains(c.Name)
group c by c.TypeCode).ToDictionary(g => g.Key, g => g);
foreach (var column in columns[TypeCode.String])
{
parameter.Parameters.Add(new LikeExpressionParameter()
{
Type = TypeCode.String,
Name = column.Name,
Value = TextBox1.Text,
Like = LikeExpressionParameter.LikeType.Contains
});
}
yield return parameter;
}
public override void LoadQueryStringParameters(System.Collections.Specialized.NameValueCollection parameters)
{
TextBox1.Text = parameters["TableTextSearch"];
}
public override System.Collections.Specialized.NameValueCollection SaveQueryStringParameters()
{
return new NameValueCollection() { { "TableTextSearch", TextBox1.Text } };
}
public override void Clear()
{
TextBox1.Text = string.Empty;
}
}
To implement filters like this one you must use the DynamicFilterForm as opposed to the DynamicFilterRepeater. The reason is that the TableTextSearch filter control is associated with any column/property in particular but the entire table instead. It may make sense to allow the FilterAttribute to be annotated at the class level to address this.
<asp:DynamicFilterForm ID="DynamicFilterForm1" runat="server" DataSourceID="GridDataSource">
<FilterTemplate>
<div>
Search
</div>
<div>
Keyword:
<dd:TableTextSearch runat="server" ID="TableTextSearch" />
<asp:LinkButton ID="LinkButton4" runat="server" CommandName="Search">Search</asp:LinkButton>
<asp:LinkButton ID="LinkButton5" runat="server" CommandName="Clear">Clear</asp:LinkButton>
</div>
</FilterTemplate>
</asp:DynamicFilterForm>
To build upon this example it would be nice to be able to search the DisplayText of foreign columns and potentially non text values. For example if the user entered a string which can be converted to a date, search all DateTime columns.
After what seems like forever, Microsoft has released the final bits for Silverlight 2. The product has come an extremely long way since it's code name of WPF/E and its formal introduction as Silverlight 1.1 during Mix 07. I am ecstatic about the concept of Silverlight and the RIA potential it brings developers. While my professional development roots started with the web, I've always felt that HTML & Javascript based applications have always been a kludge. The stateless, scripted environment built on what started as a linkable document format quickly outgrew it's original architecture.
Silverlight 2 brings us that green field development experience all developers dream of. The "I could do this so much better only if I didn't have to worry about ..." feeling we all get when digging into an existing code base. Now that Microsoft has released the technology it is up to us, the developer community, to start creating best practices around developing on this new technology. It is looking to be an excellent next year for Rich Internet Application space.
Tim Heuer has an excellent blog post on what you need to get started with Silverlight 2 development. On a very interesting side note, Eclipse will have support for Silverlight 2... cross browser, cross platform and cross IDE.
Source control, or revision control, is part of almost every developers daily activities. Some days, it is their only activity. Especially those still using Visual Source Safe. :) Yet it seems that many of us have an extremely hard time with this vital software development tool. I believe this is because of two reasons: 1) it is hard! 2) we are never really taught source control in school.
My first experience with source control was when I started my internship during freshman winter break. Never once in the next 6 years of schooling was source control taught. We had a few classes which used source control, but it was assumed that everyone knew how to use it. In my experience, developers typically are shown how to use source control during their first day or two on the job by another developer, after that it's "don't break the build".
So why is source control so hard? Well you have a lot going on. Ask any developer who has ever worked on a project with an occasionally connected system and they will tell you that the master to master synchronization between the two data sources was the most complicated aspect of the system. What was meant to change? How do I handle conflict? Was this deleted from one system or created in another? To manage this the developer usually tries to accomplish a small set of synchronization rules, but leaves the rest to the user to decide what the intention of the synchronization was. This means that the users need to be taught how to use the tool. In our case, as developers, there are very few rules and the onus is on us to correct anything the system can't figure out.
In addition to source control being hard, we have made it harder by implementing it two different ways, exclusive check-out/in and version merging repositories.
Visual Source Safe is an exclusive source control system which means that the system only allows one person to check-out a file; all other users can read the file but not write to it. Once the user is done they check-in their change set. This is the 'safest' form of source control to prevent against unwanted sides effects within a single file. Most developers on the Microsoft platform are used to this version.
Team Foundation Server (by default) and Subversion are version merging repositories. This means that everyone has the ability to write to their local files. When the developer is done with their changes they merge them with the current version within the repository. Because you do not exclusively check out files you aren't ensured that the file hasn't changed since you started working with it. The developer, that's you, must carefully merge the two files together. The source control merge tool checks for conflicts at the line level. This means that if a given line is changed in either the local or server copy the source control will accept the change automatically. If both lines have changed, a merge conflict is logged and the user will be prompted to correct the issue. I will be going into more detail on how to handle merge conflicts in a later post.
One of my roles within Catalyst as an architect and our TFS admin has been to define a source control process for projects moving forward. I will also be working to educate our developers on that process and to depend their knowledge of source control usage. This is going to be done through my blog and several presentations given during Lunch & Learns. These presentations are also available to our clients, if they would like to attend.
When I first create a project in Team Foundation Server, I immediately create the following folders under the root of that source control repository:
The trunk is where you build and deploy from, no development is done in the trunk. Developers when assigned a task create a branch under branches, sometimes called dev, for their development. This is where they begin to code. This allows them to check code into the server before they have completed their tasks and it will not impact other developers or the build. This also gives architects or team leads to ability to review code before it is merged into the trunk.
After a developer is done with a task, they merge their branch back into the trunk. During this time they check to ensure that the code they are checking in doesn’t reference any code that has changed, due to other developers merging into the trunk. Building and running automated unit tests are the easiest ways to due a quick gut check. In larger projects, someone or even a team is responsible merging into the trunk.
When the deployment team goes to make a release build they branch the trunk to releases. QA and support begin working with the release branches so not to impact new development. Subsequent patches when released are then branched using a major\minor\revision hierarchy. If a bug is identified to affect the trunk, the code which resolved the bug is also merged with the trunk.
From a testing point of view, unit testing is performed at the branch level before merges can be performed. Complete unit testing and functional testing is done on the trunk nightly. The trunk is also where most of the reporting is performed such as static code analysis, code churn, etc…
Last month Catalyst Software Solutions, my employer, official became a member of the Visual Studio Team System Inner Circle. We have been working with Angela Binkowski over the last couple of months to complete our enrollment within the Inner Circle. This effort was driven by Dan Noone and he engaged me to help with the practice.
So, what is the Inner Circle? Well instead of trying to put it into my own words, I am going to grab the overview from the Microsoft document:
The Visual Studio Team System Inner Circle is an initiative (“VSTS Inner Circle”) to train, enable and engage with a key set of specialized application life-cycle management partners worldwide who:
- Commit to meeting enrollment requirements (by the end of the Inner Circle initiative) for future Application Life-cycle management sub-specialization within the Microsoft Partner Program’s Custom Development Solutions competency
- Engage deeply with the Developer & Platform Evangelism (“DPE”) sales and marketing field to proactively drive solution sales of Visual Studio Team System software development tools;
- Deliver one or more consulting/implementation/training service offerings to enable customers to improve their development capabilities and achieve ROI on their Team System tools investment, for example:
- Instructor led deep-dive training/coaching workshop services
- Customization, integration/extension, and deployment services
- Process design & Improvement consulting services
- Software Quality implementation/Testing services
- Proactively share engagement best practices/learnings with Inner Circle partner community
- Provide constructive feedback to advance adoption and sales of Team System products
Inner Circle is a bridge initiative delivered in conjunction with the Microsoft Partner Program to assist deeply committed Team System partners prior to the launch of the Application Life Cycle Management specialization within the Microsoft Partner Program’s Custom Development Solutions Competency. Inner Circle is currently limited to ~ 300 partners worldwide and will become Microsoft Partner Program’s new Application Life Cycle management specialization.
I am super excited about this because software engineering is one of my passions and I now get to spend more dedicated time working with the process and tools which make developing software easier, faster, and more enjoyable. I've had a lot of background in the area in school with my B.S. in Computer Science followed by another two years studying Software Architecture and Project Management during my M.S. in Software Engineering. Since then I, as many developers have, worn all hats of the software development lifecycle at some point or another.
So, what does this mean? Well first off it means you will start seeing more TFS content on my blog. I will be starting a series of posts around Team Foundation Server, the Visual Studio Tools, and Application Lifecycle improvements. Catalyst is also going to begin hosting VSTS Lunch & Learn sessions which will help introduce our clients and perspective clients to the benefits of VSTS. These sessions will typically also be available as screen casts and potentially webinars. I've also committed to be speaking at user groups around the area, starting with the VSTS user group in early November.
So stay tuned for content and event announcements I will post them regularly.
One of the new features I released with Dynamic Data Filtering 1.10 is the DynamicFilterRepeater control. This control was added based on requests from several people who have implemented Dynamic Data Filtering in their applications. The idea is to use the model metadata to generate the set of filtering controls on each page as opposed to using the DynamicFilterForm. This is a great addition because it allows developers to annotate their model and modify their PageTemplates to get full Dynamic Filtering capabilities throughout the site.
The first step in using the DynamicFilterRepeater is to replace the existing FilterRepeater on either the DynamicData\PageTemplates\List.aspx or DynamicData\PageTemplates\ListDetails.aspx page.
In this example we will focus on the List.aspx page. On the List.aspx page, the default FilterRepeater controls looks something like:
<asp:FilterRepeater ID="FilterRepeater" runat="server">
<ItemTemplate>
<asp:Label runat="server" Text='<%# Eval("DisplayName") %>' AssociatedControlID="DynamicFilter$DropDownList1" />
<asp:DynamicFilter runat="server" ID="DynamicFilter" OnSelectedIndexChanged="OnFilterSelectedIndexChanged" />
</ItemTemplate>
<FooterTemplate><br /><br /></FooterTemplate>
</asp:FilterRepeater>
Delete it!
Next drag the DynamicFilterRepeater from the tool box on to the form. You will get markup that looks like the following:
Tip: I HIGHLY recommend you do this in the designer view. If you do you will get prompted to create the FilterTemplates directory, if it is not already created. References to Catalyst.Web.DynamicData and Catalyst.ComponentModel.DataAnnotations will also be added.
<asp:DynamicFilterRepeater ID="DynamicFilterRepeater1" runat="server">
<HeaderTemplate>
<div>
Search</div>
</HeaderTemplate>
<ItemTemplate>
<div>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>'></asp:Label><asp:DynamicFilterControl
ID="DynamicFilter" runat="server">
</asp:DynamicFilterControl>
</div>
</ItemTemplate>
<FooterTemplate>
<div>
<asp:LinkButton ID="SearchButton" runat="server" CommandName="Search" Text="Search">
</asp:LinkButton><asp:LinkButton ID="ClearButton" runat="server" CommandName="Clear"
Text="Clear">
</asp:LinkButton></div>
</FooterTemplate>
</asp:DynamicFilterRepeater>
This is the default template for items within the DynamicFilterRepeater and is very similar to the FilterRepeater we just deleted. You can customize this, but you must, MUST, MUST have one and only one DynamicFilterControl with the ID="DynamicFilter" in the ItemTemplate. The DynamicFilterRepeater container uses this to create your filtering controls.
After we have the DynamicFilterRepeater control completed, we need to replace the LinqDataSource with a DynamicLinqDataSource. The existing LinqDataSource should look something like this:
<asp:LinqDataSource ID="GridDataSource" runat="server" EnableDelete="true" EnableUpdate="true">
<WhereParameters>
<asp:DynamicControlParameter ControlID="FilterRepeater" />
</WhereParameters>
</asp:LinqDataSource>
Don't delete it. Switch to the designer view and select your DynamicFilterRepeater and then the Actions pop-up arrow. This will allow you to select a DataSource. Select your target datasource, in this case GridDataSource, from the drop down list. You will see an action called UpgradeData source appear in the Action popup, hit it. This will automatically change your LinqDataSource to a DynamicLinqDataSource, pretty cool, huh?
Your data source should now look like this (notice the removal of the DynamicControlParameter tag!):
<asp:DynamicLinqDataSource ID="GridDataSource" runat="server"
EnableDelete="True" EnableUpdate="True">
</asp:DynamicLinqDataSource>
If you dragged the DynamicFilterRepeater onto the form in DesignView, it will automatically have added a reference to Catalyst.ComponentModel.DataAnnotations, if not you must add a reference. It should be in the list under the .NET tab, otherwise browse to %PROGRAMFILES%\Dynamic Data Filtering\bin.
The final step is to modify the metamodel. Since the samples provided with the installer use the AdventureWorksLT2008 database I am going to annotate the Product class. This is an example of the Product class and annotations.
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Catalyst.ComponentModel.DataAnnotations;
namespace AdventureWorks.BusinessObjects
{
[System.ComponentModel.DataAnnotations.MetadataType(typeof(ProductMetadata))]
public partial class Product
{
/// <summary>
/// This is the Metadata for the parent Product class. It is a private interface to prevent
/// consumers from attempting to instantiate it or even see it.
/// </summary>
private interface ProductMetadata
{
[Filter(FilterMode = FilterControlMode.Contains)]
string Name { get; set; }
[Filter(FilterMode = FilterControlMode.Contains)]
[DisplayName("Product Number")]
string ProductNumber { get; set; }
[Filter(FilterMode = FilterControlMode.Contains)]
string Color { get; set; }
[Filter(FilterMode = FilterControlMode.Range)]
[DisplayName("List Price")]
decimal ListPrice { get; set; }
[Filter(FilterMode = FilterControlMode.Equals)]
[DisplayName("Product Model")]
ProductModel ProductModel { get; set; }
[Filter(FilterMode=FilterControlMode.Equals)]
[DisplayName("Product Category")]
ProductCategory ProductCategory { get; set; }
[ScaffoldColumn(false)]
Guid rowguid { get; set; }
[ScaffoldColumn(false)]
DateTime ModifiedDate { get; set; }
}
}
}
One thing to note in this example is that I have made the Metadata class a private nested interface of the Product class. I have done this to prevent visibility from outside classes and also to prevent any code within the Product class from attempting to instantiate a instance of that type. While giving a presentation last week, Scott Seely asked if this was possible, we tried it on the stop and it worked like a charm.
Now run the solution and you should have FilterControls defined for List.aspx page template.
After almost a month of sporadic work on Dynamic Data Filtering I am happy to announce that I am releasing the next version. This version includes several new features and a bug fix. It is downloadable from CodePlex.
New Features
Dynamic Filter Repeater
Based on suggestions I have added a Dynamic Filter Repeater. This control uses the FilterAttributes annontated in your MetaModel to automatically populate the list of filters for a given page. This is most useful if you modify your PageTemplates/List.aspx & PageTemplates/ListDetails.aspx pages. Filtering is OPT-IN!
Visual Studio Integration
Dynamic Data Filtering now has a design time experience. I have added design time rendering to the DynamicFilterForm and new DynamicFilterRepeater. The first time you drag either control on to the form the designer will automatically create the DynamicData/Filters folder and populate the folder with the default templates provided. You will also see a designer action, "Upgrade DataSource", which will convert a LinqDataSource to a DynamicLinqDataSource.
I have also added item templates to the Add New Item... window which will add a filter to the DynamicData/Filters folder for you. Currently I have templates for the standard equals operator and range. I believe these are the two most common filters used, let me know if you'd like the others and I will add them in the next release.
Thank you David and Joe from the ASP.NET team for their help with the designer support.
Thank you Steve for the icon work.
Installer
Dynamic Data is now distributable via an MSI installer. This installer will install to %Program Files%\Dynamic Data Filtering\ by default. Included in this folder are the binaries, samples and the default templates. The installer also automatically adds the VS integrations mentioned above. This was my first experience with WIX and I must say I am impressed and have found my new installer development technology.
Thank you James who helped convert the C# examples and templates to VB.
Bug Fixes
It was identified that multiple queries were being performed against the database on pages that had a DynamicFilterForm on them. It was found that this was caused by the BaseDataSource.PerformSelect() method. This method has been overridden to prevent this behavior in both the DynamicFilterForm and DynamicFilterRepeater.
The recent buzz on my blog roll has been that Microsoft has announced that jQuery will be being distributed with the next version of ASP.NET. I think that this is a HUGE move for Microsoft's relationship with the open source community. Not only are they going to be bundling the most popular javascript library, but they will also be contributing to the project as an equal to the rest of the project's developers.
This is also going to help me as a consultant who often deals with companies who stay away from open source projects and non-Microsoft tools.
For the last several weeks I have been engaged at a client on a project originally written by another consulting firm. The project is an ASP.NET 2.0 application and the design isn't the best. My role is to help get them through this last round of stabilization and out the door. The web application is AJAXified with the use of UpdatePanels everywhere. There is also heavy use of ViewState to persist objects (such as DataSets and DataTables!) between post backs. We are now doing some performance testing and it has become obvious that ViewState size is going to be an issue for users oversees. Some pages had as much as 75k in ViewState. ViewState was over twice as big as RenderSize! To make things worse a lot of this was hidden by the fact that the ViewState grew during UpdatePanel async postbacks.
The project is in triage mode and there isn't time to be rearchitecting or refractoring anything. To help figure out which pages needed work the most, I implemented a simple HttpModule that calculates the size of the ViewState on each page. I implemented log4net to log the messages which will allow for configuration after the site goes live.
public class ViewStateSizeLoggerModule : IHttpModule
{
private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public ViewStateSizeLoggerModule() { }
public void Dispose()
{
}
public void Init(HttpApplication context)
{
if (_log.IsInfoEnabled)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
}
void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
if (app.Request.Url.OriginalString.Contains(".aspx"))
{
bool isAsyncPostback = !string.IsNullOrEmpty(app.Request.Headers["x-microsoftajax"]);
app.Response.Filter = new ViewStateSizeLogger(app.Request.Url.PathAndQuery, isAsyncPostback, app.Response.Filter);
}
}
private class ViewStateSizeLogger : Stream
{
private Stream _response;
private string _pageName;
private bool _isAsyncPostback;
public ViewStateSizeLogger(string pageName, bool isAsyncPostback, Stream response)
{
_pageName = pageName;
_isAsyncPostback = isAsyncPostback;
_response = response;
}
public override bool CanRead
{
get { return _response.CanRead; }
}
public override bool CanSeek
{
get { return _response.CanSeek; }
}
public override bool CanWrite
{
get { return _response.CanWrite; }
}
public override void Flush()
{
_response.Flush();
}
public override long Length
{
get { return _response.Length; }
}
public override long Position
{
get { return _response.Position; }
set { _response.Position = value; }
}
public override int Read(byte[] buffer, int offset, int count)
{
return _response.Read(buffer, offset, count);
}
public override long Seek(long offset, SeekOrigin origin)
{
return _response.Seek(offset, origin);
}
public override void SetLength(long value)
{
_response.SetLength(value);
}
public override void Close()
{
_response.Close();
}
int _length = 0;
public override void Write(byte[] buffer, int offset, int count)
{
string viewStateHeader;
string viewStateFooter;
if (_isAsyncPostback)
{
viewStateHeader = "hiddenField|__VIEWSTATE|";
viewStateFooter = "|1|";
}
else
{
viewStateHeader = "<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\"";
viewStateFooter = "/>";
}
string html = System.Text.Encoding.Default.GetString(buffer);
int startingIndex = 0;
if (_length == 0)
{
startingIndex = html.IndexOf(viewStateHeader);
if (startingIndex >= 0)
startingIndex += viewStateHeader.Length;
}
if (_length != 0 || startingIndex >= 0)
{
int endingIndex = html.IndexOf(viewStateFooter, startingIndex);
if (endingIndex == -1)
{
_length = html.Length - startingIndex + _length;
}
else
{
_length += (endingIndex - startingIndex);
_log.InfoFormat("ViewState Size for page {0}: {1:###,###,###} bytes", _pageName, _length);
_length = 0;
}
}
_response.Write(buffer, offset, count);
}
}
}
I'm giving my first presentation at the Lake County .NET Users Group (LCNUG) on Thursday, September 25th. The topic is on ASP.NET Dynamic Data, a new feature released with the .NET Framework 3.5 SP 1. I plan to make this presentation extremely code based and create a simple, but functional, automobile classified web site. The abstract for the presentation is located below, along with details on the event. I will be posting the power point slides and code samples here, after the presentation.
Presentation Abstract
ASP.NET Dynamic Data is a new framework released with the .NET Framework 3.5 SP1 that lets you create data-driven ASP.NET Web applications easily. It does this by automatically discovering data-model metadata at run time and deriving UI behavior from it. A scaffolding framework provides a functional Web site for viewing and editing data. You can easily customize the scaffolding framework by changing elements or creating new ones to override the default behavior. Come see how ASP.NET Dynamic Data can drastically reduce development time, while still giving you the flexibility necessary to create rich data driven web applications.
Meeting Time & Location
Subs and will be provided at 6:30. Talk starts at 7:00.
Overall, I love Visual Studio. Every version gets better than the last. I believe that is the single most productive tool a developer can use. Eclipse comes in a close second, but this may only be because I live in Visual Studio a lot more then Eclipse and I know Visual Studio's feature set much better.
But the ONE thing that annoys me more than anything is accidentally hitting the F1 Key and brining up help. I recently installed a 3rd party component and it merged with my Visual Studio help files, so I am stuck with a help update in progress window:

Normally I am fine with this functionality, yes F1 should go to help and I do use the MSDN Library quite frequently. But the true issue is that this locks the Visual Studio process from continuing to do work, if you attempt to click on VS or interact with it you receive the following Delay Notification:
Why does opening, and possibly re-indexing, need to be an synchronous operation?!??! Seriously? I managed to type this blog post out and I am still waiting to get back to coding.
</rant>
Last month while I was up in Redmond I meet with the members of the ASP.NET Dynamic Data team and we talked about how to resolve several issues. The main focus was to remove the need for Reflection to access non-public framework members. Based on these changes I am now comfortable with the project and I am publishing the code to the community through CodePlex.
The URL to the CodePlex project is http://www.codeplex.com/DynamicDataFiltering. I am looking for contributors if anyone is interested in helping out.
I've been working with the 3.5 Framework pretty much exclusively for last 3 months and I just recently ran across one of the new features that I some how missed, Dictionary & Collection Initializers.
Before the C# 3.0 the only collections you could initialize in-line where arrays. This always left me doing things like:
List<string> list = new List<string>(new string[] { "Cubs", "Sox" });
Now, you can use the same syntax to declare non-array collections as well as dictionarys. Declaring the same collection now looks like this:
List<string> list = new List<string>() { "Cubs", "Sox" };
Collection initializers are great and all, but using this on dictionarys is really cool especially when I am prototyping abstract service factories and I don't want to have to declare a static method to initialize the dictionary. I wrote this piece of code today and was amazed at how clean it looked:
public static class ServiceFactory
{
private static Dictionary<Type, Type> ServiceDictionary = new Dictionary<Type, Type>()
{
{typeof(IValidateAddress), typeof(USPS.AddressValidationService)},
{typeof(ICityStateLookup), typeof(USPS.CityStateLookupService)}
};
public static TService CreateService<TService>()
where TService : IService
{
TService service = (TService)Activator.CreateInstance(ServiceDictionary[typeof(TService)]);
service.Initialize();
return service;
}
}
I'm not really sure what to call this post, so it's just the name of the control I wrote. A reader left me the following message on a previous post during this series on the extended DynamicDataFilter:
Hi
I was wondering if you could guide me on how to do the following:
On every List page, I need a dropdownlist populated with all the column names from the Table. Adjacent to that should be a textbox where the user can enter some text. And then a 'Search' button.
When clicked on this button, the following should happen:
Perform search on the Table where dropdownlist.selectedcolumnname CONTAINS textbox.text.
Repopulate Gridview with the search results.
I'd appreciate any help or atleast an idea on how to go about this. I'm new to Dynamic Data
Abby, unfortunately the functionality you are looking for isn't currently supported in DynamicData, the main issue is that the LinqDataSource does not understand CONTAINS the where parameters you supply are all equals. But, the DynamicData Filtering I have written does support this. (My code isn't production quality, and should only be used in production at your own risk.) Here is a quick screen shot:
To allow for this I created a ColumnContains control which has a DrowDownList of the columns available in the DataSource's Table and a TextBox which accepts your CONTAINS value.
<table>
<tr>
<td>
<asp:DropDownList ID="ddlColumn" runat="server">
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="tbText" runat="server"></asp:TextBox>
</td>
</tr>
</table>
The code behind for the control is responsible for binding the list of string based columns to the DropDownList and creates the LikeExpressionParameter which is responsible for the LIKE query.
public partial class ColumnContains : Catalyst.Web.DynamicData.FilterTemplateUserControlBase
{
protected void Page_Init(object sender, EventArgs e)
{
ddlColumn.DataTextField = "Name";
ddlColumn.DataSource = Table.Columns.Where(c => c.TypeCode == TypeCode.String);
ddlColumn.DataBind();
}
private MetaTable Table
{
get
{
IDynamicDataSource source = this.FindDataSourceControl();
if(source != null)
return source.GetTable();
return null;
}
}
public override IEnumerable<Parameter> GetWhereParameters(IDynamicDataSource dataSource)
{
yield return new LikeExpressionParameter()
{
Name = ddlColumn.SelectedValue,
Like =