ASP.NET Web Forms MVP

Update: Just found some great tutorials and articles on the MVP wiki here: http://wiki.webformsmvp.com/index.php?title=Spread_the_Word

ASP.NET MVC might be the new kid on the block, but there are still a host of compelling advantages to ASP.NET Web Forms.

The ASP.NET Web Forms MVP project is about bringing the love back to Web Forms through a renewed approach to using it – an approach that facilitates separation of concerns and testability whilst maintaining the rapid development that Web Forms was built to deliver.

http://webformsmvp.com/

This is really cool stuff – we’ve just started using it in our development and I can already see the benefits to plain Web Forms or MVC. Granted, if you’ve already developed a pure MVC site, this probably won’t be useful to you, but if (like most of us, I assume) you have an existing ASP.NET Web Forms site and want to try the features of MVC without completely rewriting your framework, I highly suggest checking this out.

I’ll try to see if I can abstract out some of our internal examples for a future blog post. =)

VS2010: My Favorite Extensions

VS2010 - My Favorite Extensions
VS2010 - My Favorite Extensions

My favorite feature of VS2010 so far is the excellent extension support, which allows me to add in my favorite plugins from the Microsoft Visual Studio Gallery.

Since there are thousands of plugins in the gallery right now, I thought it might be useful to share the most useful extensions I’ve found (and currently use) so far:

In alphabetical order…

  1. AnkhSVN
    AnkhSVN is a Subversion Source Control Provider for Microsoft Visual Studio 2005, 2008 and 2010.
    AnkhSVN provides source code management support to all project types supported by Visual Studio and allows you to perform the most common version control operations directly from inside the Microsoft Visual Studio IDE.
    The Pending Changes dashboard gives you a unique insight in your development process and provides easy access to the source code and issue management features. The deep source code control (SCC) integration allows you to focus on developing, while AnkhSVN keeps track of all your changes and provides you the tools to effectively handle your specific needs.
  2. Code4Blog
    Code4Blog is a Visual Studio 2010 extension that allows to convert any code supported by Visual Studio IDE to HTML format with the same structure and colors. Main purpose of this extension is to prepare a code snippet to be published in rich documents, for example in blog posts, Microsoft Word documents or Help files. Some additional styling could be applied: max width and height of the code block, custom background (per code line), font family and font size, line numbering and others.
    Code4Blog is now published on CodePlex. You are welcome to work with the source code directly!
  3. JSEnhancements
    This extension provides outlining and matching braces highlighting features for Visual Studio JavaScript and CSS editor.
    Works both in JS/CSS files and HTML script/style blocks.
    Outlining is like in C# editor. It outlines {}’s, []’s and #region tags
    Brace highlighting is made from MSDN example.
    CodePlex page: http://jse.codeplex.com/
  4. PowerCommands for Visual Studio 2010
    PowerCommands 10.0 is a set of useful extensions for the Visual Studio 2010 adding additional functionality to various areas of the IDE.
    Visit the VSX Developer Center at http://msdn.com/vsx for more information about extending Visual Studio.
  5. PowerConsole
    This extension provides an extensible VS command window with default PowerShell integration. You can now script Visual Studio interactively in PowerShell, and enjoy familiar VS style syntax coloring and tab-completion.
    Prerequisite: Visual Studio 2010 RC (or above) + Windows PowerShell v2 (or above). After installation, open the new tool window from View->Other Windows->Power Console.
  6. Productivity Power Tools
    A set of extensions to Visual Studio Professional (and above) which improves developer productivity.
    (Tons more info at the VS Gallery Page: http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef)
  7. Regex Editor
    This sample was built to ease your pain when working with regular expressions.  It rehosts the editor in a dialog box and provides a basic language service to provide colorization, brace matching, sample testing grouping and selection tracking.  It shows re-hosting of the editor in a tool window, and provides a nice starting point for similar projects.
  8. VS10x Code Map
    VS10x Code Map is a Visual Studio 2010 extension that displays a graphical nested representation of the current editor window code (C# and VB.NET). It helps the developer  visualize type nesting, implemented interfaces, regions, member type and scope, as well as  quickly navigate to their respective position in the code editor.
  9. VS10x Method Block Highlighter
    Highlight entire methods with a colored-marker-like (standard green, yellow, cyan or magenta) background.

Software Development Posts

I’ve started to compile my software development related posts into a nice little category for your reference here:

https://blog.wolffmyren.com/category/software-development/

There’s more to come from that category, both old posts and new, as I dig out old articles and categorize them correctly. =)

For a quick reference, please check out the following articles – they’re the most useful of the bunch so far, IMO:

Thanks for visiting! =)

Quick Update: CSS/JS Auto-Minification in ASP.NET

I’ve been trying for weeks to write up a good technical article about a recent CSS/JavaScript minification handler for ASP.NET (ASHX/HttpHandler) that I whipped up, but our current release has been so busy, I haven’t had enough time to really put it all together.

Just wanted to post a quick update for everyone who mentioned they’d like to hear about it that I’ll be posting more info as soon as I can. =)

In the meantime, here are links to some of the articles that helped me construct the custom handler in the first place:

And, my own pride and joy (this damn code took me forever, only because I had to do all sorts of research and testing with Regex in C#), the function that will fix relative paths in the combined CSS files by replacing them with absolute paths based on your application root:

/// <summary>
/// CSS Only: Replaces relative paths in url(...) properties within the specified script.
/// </summary>
/// <param name="scriptBody">The pre-combined script, passed from CombineScripts().</param>
/// <param name="scriptPath">The relative path where scripts are located (ex: ~/CSS/).</param>
/// <param name="applicationPath">The absolute application path. (ex: /ApplicationRoot).</param>
/// <returns></returns>
private static String FixRelativePaths(String scriptBody, String scriptPath, String applicationPath)
{
 scriptPath = VirtualPathUtility.AppendTrailingSlash(scriptPath);
 String relativeRoot = VirtualPathUtility.Combine(applicationPath, scriptPath);

 Regex cssUrlReference = new Regex("(?<=url\\()(.+?)(?=\\))", RegexOptions.Singleline);
 Regex invalidPathChars = new Regex("[ '\"]+", RegexOptions.Singleline);

 MatchCollection urlMatches = cssUrlReference.Matches(scriptBody);
 foreach (Match m in urlMatches)
 {
 String oldPath = Regex.Replace(m.Value, "[ '\"]+", "");
 String newPath = VirtualPathUtility.Combine(relativeRoot, oldPath);
 newPath = VirtualPathUtility.ToAbsolute(newPath);
 scriptBody = scriptBody.Replace(m.Value, newPath);
 }

 return scriptBody;
}

I’d love to read your comments and/or questions about this code, so please feel free to post your thoughts in the comments on this post.

I’ll try to get you the full meal deal on this code as soon as I can. =)

C# Corner: How to get distinct rows from a DataSet or DataTable

Not without its typos, but quite a helpful article nonetheless… 😉

One of the common issues in data layer is avoiding duplicate rows from dataset or datatable. I saw many people are writing separate function and looping through the datatable to avoid the duplicates. There is more simple ways available in .Net but people are unaware about this. I thought of writing a blog about this because I saw many blogs which mislead the people from right path. Thers is no need of looping or no need of logic are required to avoid the duplicates.

Following single line of code will avoid the duplicate rows.

ds.Tables[“Employee”].DefaultView.ToTable(true,”employeeid”);

ds – Dataset object

dt.DefaultView.ToTable( true, “employeeid”);

dt – DataTable object

First option in ToTable is a boolean which indicates, you want distinct rows or not?

Second option in the ToTable is the column name based on which we have to select distinct rows.

Simple right, this option is the last one so most of the people didn’t got the time to find it. Now your code will look much cleaner without those junk codes.

via How to get [distinct] rows from a DataSet or Datatable? by shyju.