using System;using System.Text;using Google.GData.Client;using System.Net;using System.Xml;using System.Text.RegularExpressions;namespace BloggerDevSample{ class ConsoleSample { /** Lists the user’s blogs. */ static void ListUserBlogs(Service service) { Console.WriteLine(“\nRetrieving a list of blogs”); FeedQuery query = new FeedQuery(); // Retrieving a list of blogs query.Uri = new Uri(“https://www.blogger.com/feeds/default/blogs”); AtomFeed feed = null; feed = service.Query(query); foreach (AtomEntry entry in feed.Entries) { Console.WriteLine(” Blog title: ” + entry.Title.Text); } } /** Lists the user’s blogs and returns the URI for posting new entries * to the blog which the user selected. */ static Uri SelectUserBlog(Service service) {…
Search Results for: css
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>…
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…
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…
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);
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
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…
C# string to Formatted HTML string
Is there a tool out there that can turn a C# string of unformatted HTML (no indentions, no new lines, etc) into a Formatted HTML string?I am in a situation where I am generating an HTML string, and I am outputting it into a multiline textbox. Write now, it is wrapping, but is showing up similar to a paragraph. I would like it to be shown as formatted HTML? It wouldn’t even have to be very nice formatting, but at least not show a paragraph of HTML.For having a good…