Pro ASP.NET MVC 5

The ASP.NET MVC 5 Framework is the latest evolution of Microsoft’s ASP.NET web platform. It provides a high-productivity programming model that promotes cleaner code architecture, test-driven development, and powerful extensibility, combined with all the benefits of ASP.NET. ASP.NET MVC 5 contains a number of advances over previous versions, including the ability to define routes using C# attributes and the ability to override filters. The user experience of building MVC applications has also been substantially improved. The new, more tightly integrated, Visual Studio 2013 IDE has been created specifically with MVC…

Windows Phone 8 Battery API

The Battery API makes a nice addition to the WP8 SDK. I can see in the near future that some applications will display the battery metrics on a Live Tile or in the application that hides the System Tray. The Battery API is pretty easy to use: Get the Battery instance with Battery.GetDefault() Bind to the event RemainingChargePercentChanged. The battery properties are: RemainingChargePercent: gets a value that indicates the percentage of the charge remaining on the phone’s battery RemainingDischargeTime: gets a value that estimates how much time is left until…

Privacy policy generator for websites and apps

This post mainly answers the question how and why you should add a privacy policy to your Windows Phone app. If you want to read a more general overview of privacy policies in mobile apps then you can read that here If you want to skip all that and just use our generator to help you make a privacy policy for your Windows Phone app then follow me Since we’ve launched our mobile apps privacy policy generator last week I’ve been wondering how good the documentation was out there regarding…

Add Rows to a DataTable

To add new records into a dataset, a new data row must be created and added to the DataRow collection (Rows) of a DataTable in the dataset. The following procedures show how to create a new row and insert it into a DataTable. Examples are provided for both typed and untyped datasets. I created this Dataset (view picture). dsOperation dt = new dsOperation(); DataRow opRow = dt.Tables[“Operations”].NewRow(); opRow[“Group”] = “FirstGroup”; opRow[“SubGroup”] = “SecondGroup”; opRow[“Debit”] = 0; opRow[“Credit”] = 10; dt.Tables[0].Rows.Add(opRow);

Proper MIME types for Embedded @font-face Fonts

After some exhaustive research, I managed to find the best server settings for serving web fonts. There are a number of font formats that one can set MIME types for, on both Apache and IIS servers. I’ve traditionally had luck with the following: svg as “image/svg+xml” ttf as “application/x-font-ttf” or “application/x-font-truetype” otf as “application/x-font-opentype” woff as “application/font-woff” (per my August 16, 2013 update below) eof as “application/vnd.ms-fontobject” According to the Internet Engineering Task Force who maintain the initial document regarding Multipurpose Internet Mail Extensions (MIME types) here: https://tools.ietf.org/html/rfc2045#section-5 … it…

Create DataTable

Data is read from a database. It is generated in memory from input. DataTable is ideal for storing data from any source. With it we take objects from memory and display the results in controls such as DataGridView. The DataTable type is a powerful way to store data in memory. You may have fetched this data from a database, or dynamically generated it. We get a DataTable with four columns of type int, string and DateTime. This DataTable could be persisted or displayed, stored in memory as any other object,…

DateDiff() function in C#

I have written the following DateDiff() function in C#. VB.NET users already had it using the Micrsoft.VisualBasic.dll assembly. Now you can use it without referencing this ‘ugly’ extra assembly. using System; namespace PureSourceCode.System { public enum DateInterval { Year, Month, Weekday, Day, Hour, Minute, Second } public class DateTimeUtil { public static long DateDiff(DateInterval interval, DateTime date1, DateTime date2) { TimeSpan ts = date2 – date1; switch (interval) { case DateInterval.Year: return date2.Year – date1.Year; case DateInterval.Month: return (date2.Month – date1.Month) + (12 * (date2.Year – date1.Year)); case DateInterval.Weekday: return…

Populate DropDownList with Selected Value in EditItemTemplate of GridView in ASP.Net

In this article I will explain with an example how to use ASP.Net DropDownList control in the EditItemTemplate of ASP.Net GridView control. I created this GridView with EditItemTemplate. <asp:GridView ID=”GridView1″ runat=”server” AllowPaging=”True” AllowSorting=”True” AutoGenerateColumns=”False” AutoGenerateEditButton=”True” DataKeyNames=”CodeAction” OnRowEditing=”GridView1_RowEditing” OnRowDataBound=”GridView1_RowDataBound” OnRowUpdating=”GridView1_RowUpdating” OnPageIndexChanging=”GridView1_PageIndexChanging” OnRowCancelingEdit=”GridView1_RowCancelingEdit”> <Columns> <asp:CommandField ShowSelectButton=”True” /> <asp:BoundField DataField=”CodeAction” HeaderText=”CodeAction” ReadOnly=”True” SortExpression=”CodeAction” /> <asp:BoundField DataField=”Description” HeaderText=”Description” SortExpression=”Description” /> <asp:TemplateField HeaderText=”Group” SortExpression=”GroupID”> <EditItemTemplate> <asp:Label ID=”Label1″ runat=”server” Text='<%# Eval(“GroupID”) %>’ Visible=”false”></asp:Label> <asp:DropDownList ID=”ddlGroup” runat=”server” DataTextField=”Group” DataValueField=”IDGroup” AutoPostBack=”True” OnSelectedIndexChanged=”ddlGroup_SelectedIndexChanged”> </asp:DropDownList> </EditItemTemplate> <ItemTemplate> <asp:Label ID=”Label1″ runat=”server” Text='<%# Eval(“GroupID”) %>’></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText=”Subgroup” SortExpression=”SubGroupID”> <EditItemTemplate> <asp:Label…

ASP.NET Menu and SiteMap Security Trimming

With ASP.NET 2005 Microsoft introduced a pretty solid menu which is integrated with a configuration driven sitemap. The cool part is that the menu can be hooked in with your security roles, so you don’t have to worry about hiding or showing menu options based on the user – the menu options are automatically kept in sync with what the user is allowed to see.   Step one – Define the Sitemap I’m using a static sitemap defined in a Web.sitemap file, and it’s especially simple since there’s no is…

Working With Share Link Task in Windows Phone 8

In this article we will learn about the Share Link Task. This task enables the user to share a link from the app itself on various social media and other sharing platforms. It can be a very useful feature for promoting your app on various platforms. Let’s see how to use it. Share Link Task This is a kind of launcher provided by Windows Phone to launch the share screen from an app so that the user can share the link. The task can be customized with various properties for…

Five documentation apps for .NET developers

Documentation is a necessary evil for software developers. While C# and VB.NET have basic facilities for commenting code and embedding XML documentation into code, turning that into a more useful form is outside the realm of Visual Studio. These five applications can help you turn your comments and notes into proper documentation.   1: Sandcastle Sandcastle is probably one of the best known documentation generators for .NET, and it has the benefit of being open source. Unfortunately, Sandcastle is difficult to use on its own, prompting a small cottage industry…

Enable GZIP Compression

A significant and growing number of apps rely on external data from remote servers or other external APIs. At some point you’ll be developing an app that downloads data in XML, JSON, HTML or some other text format. The problem is that the network condition cannot be relied upon when it comes to mobile devices. A user can be on an EDGE network one minute, and the a 3G network the next. Whatever the scenario, you don’t want to keep your user waiting! One option to reduce the file size…