Oggi è stato pubblicato il libro di Enrico Rossini Creare App per Windows Phone 8 Concetti di base. Nel mercato degli smartphone è arrivato da qualche tempo il nuovo sistema operativo di Microsoft, Windows Phone, che rappresenta un taglio netto con il passato: nuova architettura, nuova user experience, nuova grafica e anche nuovi strumenti di sviluppo. Con questo libro, partendo dalle basi fino ad arrivare agli aspetti più avanzati, scopriamo tutte le caratteristiche della piattaforma e quali sono gli strumenti che abbiamo a disposizione per creare applicazioni originali e innovative.…
Month: May 2014
Display list of files from Server folder in ASP.Net GridView
In this article I will explain how we can save and retrieve files from Windows Folder and Directory and display them in ASP.Net GridView control with download and delete option. HTML Markup Below is the HTML Markup of the page, where I have an ASP.Net control FileUpload to upload files, a Buttoncontrol to trigger file uploads and an ASP.Net GridViewcontrol to display the files from folder. <asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”false” EmptyDataText=”No files uploaded”> <Columns> <asp:BoundField DataField=”Text” HeaderText=”File Name” /> <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID=”lnkDownload” Text=”Download” CommandArgument='<%# Eval(“Value”) %>’ runat=”server” OnClick=”DownloadFile”></asp:LinkButton>…
How to create simple Background Agent in Windows Phone
This article provides a minimal example on how to create Background Agents (Tasks) in Windows Phone. There is a more comprehensive example on Dev Center How to implement background agents for Windows Phone. Introduction Windows Phone apps are made dormant when running in the background or when the phone is locked (to conserve device memory and battery life). If your application needs to perform processing when it is (may be) in the background you can use a background agent to run activities according to some schedule. Background agents are…
Checking the Internet connection type on Windows Phone
All Windows Phone applications that use Internet data should always check if there is a valid Internet connection; if there is no connection, a proper message should be displayed to the user. The correct way to check if you have an Internet connection (WIFI, Ethernet, or none) is by checking the property: NetworkInterface.NetworkInterfaceType Unfortunately checking this property is a synchronous operation, so calling it in the UI thread can block the UI for many seconds. If your application relies on a specific server you might be tempted to simply check…
Checking network availability in Windows Phone
Many applications utilize network connection for various purposes like feeds, sending & receiving data to/from server, etc. The following article explains how one can detect if the network connection is available or not. Network API Information NetworkInterface Class helps in providing network information to the developers. It helps detect if the network is on/off, address etc. NetworkInterface::GetIsNetworkAvailable is used to check if the network connection is available.The network connection is considered to be available if interface is not in loopback or is marked as “upâ€. Namespace: System.Net.NetworkInformation Example Code to…
Enabling quick resume for Windows Phone apps
This article explains how to quickly resume the Windows Phone 8 application which is put in the background. Introduction Whenever your app loses focus (is put in the background), an instance of the app is saved. This instance is used to resume the app if the user tasks to it from a deep link or returns to it by selecting the back button on the foreground app. However if the user relaunches the app by selecting its icon on the start screen, by default the stored instance is removed…
Make the application loosely coupled
In this series of tutorials, we build an entire Contact Management application from start to finish. The Contact Manager application enables you to store contact information – names, phone numbers and email addresses – for a list of people. We build the application over multiple iterations. With each iteration, we gradually improve the application. The goal of this multiple iteration approach is to enable you to understand the reason for each change. Iteration #1 – Create the application. In the first iteration, we create the Contact Manager in the simplest…
Add form validation ASP.NET MVC
Building a Contact Management ASP.NET MVC Application (C#) In this series of tutorials, we build an entire Contact Management application from start to finish. The Contact Manager application enables you to store contact information – names, phone numbers and email addresses – for a list of people. We build the application over multiple iterations. With each iteration, we gradually improve the application. The goal of this multiple iteration approach is to enable you to understand the reason for each change. Iteration #1 – Create the application. In the first iteration,…
Dynamic Pivot Linq C#
I have the following collection / table Category Type Detail CostAuto Hybrid AC 80Auto Hybrid Sunroof 100Auto Standard AC 120Motorcycle Standard Radio 60 Is there a way with linq to get this to pivot to look like this? Category Type AC Radio Sunroof Auto Hybrid 80 0 100 Auto Standard 120 0 0Motorcycle Standard 0 60 0 use the let keyword to generate a key for use with the group by clause like so: var query = from item in list let key = new { Category = item.Category, Type…
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…
DVLUP
DVLUP HELPS DEVELOPERS BECOME MORE SUCCESSFUL HAVE FUN. EARN REWARDS. BUILD NEW IDEAS. By joining DVLUP, you’ll get exclusive access to App Challenges, news, events, partner opportunities and more. Earn points to redeem for Rewards, including promotional placements for your Apps. And if exclusive access and glory aren’t enough, we’ve got more badges than the lost & found at a police convention. Let’s get playing. DVLUP Has Leveled Up
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…
How to get the server IP Address?
string myHost = System.Net.Dns.GetHostName(); // Show the hostname MessageBox.Show(myHost); // Get the IP from the host name string myIP = System.Net.Dns.GetHostEntry(myHost).AddressList[index].ToString(); // Show the IP MessageBox.Show(myIP);
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);
Getting error “The ‘Microsoft.ACE.OLEDB.12.0’ provider is not registered on the local machineâ€
While I was trying to connect to an Access Database from Visual Studio 2010 on my Windows 7 x64 server, I got the following error message, SOLUTION After a detailed research on the above error message, I was able to identify that the 64-bit framework dlls weren’t able to 32-bit versions of the ‘Microsoft.ACE.OLEDB.12.0‘ provider modules. Since I was running Visual Studio on a 64-bit machine, IIS 7 is not (by default) serving 32-bit applications. However, I noticed that the database engine operated on 32-bit. I followed these steps to…
Accessing SMTP Mail Settings defined in Web.Config File Programmatically
I needed to read my SMTP email settings defined under system.net section in my web.config file. In order to use eNewsLetter and other SiteAdmin CMS modules that sending email notifications; you can setup your web.config to defind SMTP services settings. Below is one example of SMTP email setting defined in web.config file:(Under <configuration> Section) <system.net> <mailSettings> <smtp deliveryMethod=”Network” from=”testuser@domail.com”> <network defaultCredentials=”true” host=”localhost” port=”25″ userName=”kaushal” password=”testPassword”/> </smtp> </mailSettings> </system.net> To Access, this SMTP Mail Setting Programatically, you need to import below namespaces: using System.Configuration;using System.Web.Configuration;using System.Net.Configuration; The .NET Framework provides…
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,…
Parse HTML page and capture contents
Here I show a simple class that receives the HTML string and then extracts all the links and their text into structs. It is fairly fast, but I offer some optimization tips further down. It would be better to use a class. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace PSC { public class Finder { public struct LinkItem { public string Href; public string Text; public override string ToString() { return Href + “\n\t” + Text; } } public class LinkFinder { public static…
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…
Log record changes in SQL server in an audit table
How to implement a log record changes in SQL server in an audit table and Entity Framework. This is the easy explanation and the code
Create a File or Folder
// Specify a name for your top-level folder. string folderName = @”c:\Top-Level Folder”; // To create a string that specifies the path to a subfolder under your // top-level folder, add a name for the subfolder to folderName. string pathString = System.IO.Path.Combine(folderName, “SubFolder”); // You can write out the path name directly instead of using the Combine // method. Combine just makes the process easier. string pathString2 = @”c:\Top-Level Folder\SubFolder2″; // You can extend the depth of your path if you…
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…