Jul2008
16

BlogEngine.NET - BookShelf Widget

by nmgomes

In order to complete my migration from 1.3 to 1.4 version I needed to replace the books control I had with a widget that do the same.

After a fast Google search I found no widget with such functionality.

Armed with lots of confidence I decided to create a new widget, the BookShelf widget, to meet my exact needs:

  • display the book thumbnail image
  • show the book name and book author name

The previous book control has been gently made available by John Dyer, and I simply didn't worry about the layout, I used the old one with minor changes on binding.

books books_edit

This widget is obviously editable since I want to manage the books in the shelf, so I create an edit interface where its very simple to add, edit and remove books.

As a final note, I can simply reaffirm that work with widgets is very simple and straight forward.

Download, try it, and naturally let me now if it meet your needs too.

Filed in: BlogEngine.NET

Jul2008
13

BlogEngine.NET - Improved LinkList Widget

by nmgomes

I've been using BlogEngine.Net 1.4.0 since last week. It wasn't easy to migrate and keep the blog stable. To keep things working I made 3 updates (1.4.06, 1.4.0.8 and 1.4.0.12) in one week.

Finally on Friday I decided to update my theme to make use of widgets. This was my I first draw back ... my blog uses two sidebars and the BlogEngine.NET only suport ONE WidgetZone on the page.

I took almost the complete weekend to override this limitation and create an improved version of the widget framework that supports multiple WidgetZones.

I still have some issues to solve, such as the Drag'n'Drop of widgets, but all the rest is completely working and I currently using it on this blog. More on this will came soon.

After solve the WidgetZone issue I found out that the available widgets weren't enough to accomplished my needs, so, I decide to improve the LinkList widget.

I needed to:

  • add support for rendering the class attribute to the anchor Html elements (see the sidebar Meta section)
  • add support for rendering an HyperLink (see the sidebar My Profiles section)

I can only say that it was really simple to create or extend an widget.

I submitted this changes on LinkList widget as a patch on BlogEngine.Net (ID 1504), and perhaps Mads adds them in some future release.

Meanwhile you can get the code here

Filed in: BlogEngine.NET

Jul2008
1

NunoGomesControlToolkit - Improving Web Apps performance

by nmgomes

A few weeks ago I told you about a control toolkit I was making.

I decided to call him NunoGomesControlToolkit and is intended to improve web apps performance by decreasing total page size. This page size reduction is achieved by decreasing control ClientID size.

This control toolkit can be applied to any existing ASP.NET 2.0 Web Aplication by using the tagmapping configuration facility.

To obtain maximum redution it's also recommended to extend webforms, masterpages and usercontrols not from regular Page, MasterPage and UserControl controls from ASP.NET framework but instead use the corresponding control from NunoGomesControlToolkit.

TagMapping is only used for markup interpretation and therefore all dynamic created controls are not mapped. To override this limitation its also included in this toolkit the DynamicControlBuilder class. Use this class to allow tagmapping over dynamic created controls.

As I promise, the control toolkit is now available at code.msdn.microsoft.com.

I'm currently applying the NunoGomesControlToolkit to the BlogEngine.NET 1.3 version, and as soon as I test it I will make it available.

kick it on DotNetKicks.com

Filed in: ASP.NET

Jun2008
21

Is Maxtor messing with his costumers pocket?

by nmgomes

A few days ago, my aunt ask me to buy her an external portable hard drive for backups.

She's an accounting freelancer and works mainly in a laptop computer. To prevent loosing data she makes periodical accounting data backups.

I ask her to see the backup data size and is small ... very small, so ... I decide to buy her a small capacity 2,5´´ external hard drive.

Here is the chosen one: More...

Filed in: Hardware

Jun2008
18

ASP.NET Controls - Improving automatic ID generation : The ShortIDs Naming Provider (Part 4)

by nmgomes

In the previous posts on this subject I wrote about why automatic ID generation should be improved and how we can improve it. Now I will step forward and show you my own implementation of a specific naming provider.

As we saw in part 3, to create a specific Naming provider you only need to develop your own implementation of SetControlID method.

I named my naming provider ShortIDsProvider and it will have only one specification to meet:

  • it will create IDs in the form Txxx

where T denotes the 'T' character and xxx denotes an unique incremental integer value.More...

Filed in: ASP.NET

Jun2008
2

ASP.NET Controls - Improving automatic ID generation : Architectural Changes ( Part 3)

by nmgomes

Naming container controls are a subclass of standard controls, that differ in the ability to manage child controls' ID, in fact, these naming container controls are the key to unique ID generation. To become a namingcontainer a regular control must implement the INamingContainer interface.

In order to override ASP.NET ID generation we will have to work in two fronts:

  • override regular controls' behavior to decouple the Control.UniqueID property from the Control.ID property
  • override naming container controls to allow us to control how ID generation is done and how to find a control 

More...

Filed in: ASP.NET

May2008
28

Less MSIèrables - Extract the content of a .MSI file

by nmgomes

Yesterday, I decided to spent some time reviewing the WindowsLiveWriter plugin gallery and search for a replacer for Steve Dunn CodeFormatter plugin. I've been using this plugin since the beginning of the year but it reveal some problems composing the Html.

My friend Paulo told me about Douglas Stockwell "Paste from Visual Studio" plugin and I decided to try this one.

I download the vspaste.msi and tried to install it without success. As far as I understood (I didn't take this to depth) the .MSI was looking for a specific registry entry and since I'm using the portable version of WLW the key wasn't found.

I knew that WLW plugins don't required any special install procedure, they just need to be in the plugins folder.

I decided then to extract the .MSI content in order to be able to copy the assembly to the correct folder in my flash drive.

Searching the web I found a little tool called "Less MSIèrables" that exactly feets my needs.

It's a free tool written in C# for .NET 1.1 that allow us to open an .MSI file, explore its contents, and extract selected items.

lessmsi

We can also run it from the command line.

Its not perfect and I found a few possible improvements:

  • GUI - adding Drag'n'Drop capability
  • GUI - adding a select/unselect all files checkbox
  • CPI - adding a -l option to list all files within a .MSI file
  • CPI - adding a -e option to extract a list of files

The good news is that author made the source code available, so anyone can extend the tool.

In conclusion, it's free, it's cool and I think I going use it many times in future, helping me to see if I really need to install a .MSI.

For those of you that prefer not to use free tools, Microsoft provides us with msiexec.exe tool. This one is available in Windows XP and higher and also allow us to extract .MSI files using the following syntax:

msiexec.exe /a vspaste.msi /qb TARGETDIR=c:\temp

Filed in: Tools

May2008
26

ASP.NET - Dynamic Control Mapping

by nmgomes

I already posted here about Tag Mapping and how helpful it can be, but naturally there's are a few improvements that I would like to see available in future framework release.

The one I expect the most is about the capability of mapping dynamic created controls using the same rules as Tag Mapping uses when interpreting the page markup.

Without this capability we can never use widely the tag mapping because whenever we need to create dynamic controls they will be strongly coupled to a specific control implementation.

Imagine this scenario:

  1. First you have built an web application that use standard ASP.NET TextBox  control, some of them dynamically created.
  2. Now, imagine that you want to reuse that application, as is, but instead of ASP.NET Textbox control you want to use your own Textbox implementation.

This task could be easily accomplished using Tag Mapping if no dynamic controls were used, but in this scenario ASP.NET give us no solution, so the application cannot be reused without modifications.

Naturally, you can copy/paste your application and make the necessary changes, or even add a few if statements, but that will only increase complexity and maintenance effort.

Until the .NET team provide us such capability we must do the magic ourselves.

My proposal is an help class (DynamicControlBuilder) that provide us two methods: GetMappedType and CreateControl.

/// <summary>
/// Gets the mapped <see cref="System.Web.UI.Control"/> type.
/// </summary>
/// <param name="type">The <see cref="System.Web.UI.Control"/> type to be mapped</param>
/// <param name="prefix">The namespace prefix.</param>
/// <returns>A <see cref="System.Type"/> object.</returns>
public static Type GetMappedType(Type type, string prefix)
{
    if (!typeof(Control).IsAssignableFrom(type))
    {
        throw new ArgumentOutOfRangeException("type", "Must inherit from Control.");
    }
    Type mappedtype;
    if (!string.IsNullOrEmpty(prefix))
    {
        TagPrefixInfo prefixinfo;
        if (!m_prefixes.TryGetValue(prefix, out prefixinfo))
        {
            throw new ArgumentException("prefix", "No prefix found.");
        }
        else
        {
            type = BuildManager.GetType(string.Format("{0}.{1}, {2}", prefixinfo.Namespace, type.UnderlyingSystemType.Name, prefixinfo.Assembly), false);
            if (type == null)
            {
                throw new ArgumentException("type", "Control not found within specified prefix.");
            }
        }
    }
    if (m_tagMappings.TryGetValue(type.UnderlyingSystemType, out mappedtype))
    {
        return mappedtype;
    }
    return type;
}

/// <summary>
/// Creates a dynamic mapped <see cref="System.Web.UI.Control"/>.
/// </summary>
/// <param name="type">The <see cref="System.Web.UI.Control"/> type to be mapped</param>
/// <param name="prefix">The namespace prefix.</param>
/// <returns>A <paramref name="T"/> object.</returns>
public static Control CreateControl(Type type, string prefix)
{
    Type mappedType = GetMappedType(type, prefix); ;
    return (Control)Activator.CreateInstance(mappedType);
}

The main goal is to enable any of the following usages:

this.Page.Controls.Add(DynamicControlBuilder.CreateControl<System.Web.UI.WebControls.TextBox>("foo"));

this.Page.Controls.Add(DynamicControlBuilder.CreateControl(typeof(System.Web.UI.WebControls.TextBox), "foo"));

this.Page.Controls.Add(DynamicControlBuilder.CreateControl(typeof(System.Web.UI.WebControls.TextBox)));

Try it !

DynamicControlBuilder.cs (7.13 kb)

kick it on DotNetKicks.com

Filed in: .NET | ASP.NET