Code
Intro to this series of posts. Some of the code I use for UI validation came from Paul Stovell, who is working on a WPF Element that acts like WinForms 2.0 ErrorProvider control. Paul's control didn't quite fit my needs, so I've tweaked a few things so I can provide visual validation in a generic fashion from my base class. All of our objects implement:Public Event InvalidProperty(string PropertyName, string ErrorMessage);Public Event Validated(object sender);Public bool IsValid; Our objects also ......
<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="DesktopBuild" xmlns="http://schemas.micro... <!-- TO EDIT BUILD TYPE DEFINITION To edit the build type, you will need to edit this file which was generated by the Create New Build Type wizard. This file is under source control and needs to be checked out before making any changes. The file is available at - $/{TeamProjectName}/TeamBui... where you will need to replace TeamProjectName ......
This code is meant for people that want to easily implement INotifyPropertyChanged after using the "prop" code snippet. It will take code that looks like this: public int DriverID { get { return _driverID; } set { _driverID = value; } } And return it like this: public int DriverID { get { return _driverID; } set { _driverID = value; OnPropertyChanged("DriverID"); } } It also will ignore any triple slash comments and #regions. So you can copy your entire #region --Properties-- into the class and it ......
I have a couple helper methods that I use all the time during my data access layer. I figured I might as well post them and hopefully help others out. I use the code from this article to pull my field names, that way I can build code like this:public override IEntity PopulateFromOpenIDataReader... dr) { const int ID = 0; const int NAME = 1; const int COMMENT = 2; const int ADDRESS1 = 3; const int ADDRESS2 = 4; Doctor rv = new Doctor(); rv.ID = (int)DataValidation.GetValu... ID, 0); ......
I've been working on implementing CoT XML standard for describing location based data. Here is the C# code for an .aspx page that will render XML More infomation about CoT can be found here: using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;u... System.Web.UI.WebControls.W... System.Web.UI.HtmlControls;... System.Xml;public partial class cot : System.Web.UI.Page{ ......
Update: 02/27/2007 added support for raw SQL Strings When I build data access layers, I like to define a const for each column in the query like this: const int CLIENTID = 0; const int STATUS = 1; const int FIRSTNAME = 2; That way, I can pull data like this: newClient.Name.FirstName = reader.GetString(FIRSTNAME); And if something changes in the database, I know I only have to change the field that FIRSTNAME references. However, sometimes, tables can be quite large and it becomes a pain in the wrist. ......
Windows has pretty good VPN management. It's pretty good at redialing the connection when the connection is dropped, and for the most part it works. However, sometimes it thinks it connected to the VPN when it's really not, and it doesn't validate the connection to a specific internal IP. I needed something that was a bit more robust and could disconnect and reconnect if it couldn't see a specific IP. This class takes a VPN connection name and an IP to ping and will use rasphone.exe to connect and ......
In a recent post, I talked about wanting a TFS group called ParaPlan_Stud that contained Kyle and myself that we could assign tasks to and view in our "My Work Items". Much thanks goes to Mickey Gousset, who wrote a book that you need to get, for helping me with this. Here is how we did it: Created Project Group call ParaPlan_Stud and added Kyle and myself to it. Edited Task.xml To access the Task, I had to edit the xml file that defines the task. Using the VS 2005 command prompt, I entered: witexport ......
According to the RSS specification, the pubDate element (when the item was published) must be formatted like this : Mon, 28 May 1979 19:45:32 GMT Here is a function that will accept a DateTime object and return a string formatted properly for pubDate: C# private string BuildPubDate(DateTime d) { try { string RV = ""; string day = d.Day.ToString(); if (day.Length == 1) { day = "0" + day; } string month = d.Month.ToString(); if (month == "1") { month = "January"; } else if (month == "2") { month = ......
The FileSystemWatcher is very useful when you need to be notified of changes made to a specific folder. You can raise an event when a new file is created, or deleted and you can also filter by file type and choose if you wish to monitor sub directories. The only problem with the object comes with large file transfers. The created event is raised as soon as the file transfer begins to your watched folder, not when the file has finished transferring. So if you need to move a file or pull data out a ......
This article will show you how to gather location information from an IP using the hostip.info API. Consuming the IPLocation Class: Private Sub Button1_Click(...) Handles Button1.Click Dim LocationObject As New IPLocation("your ip") MessageBox.Show(LocationObj... MessageBox.Show(LocationObj... MessageBox.Show(LocationObj... MessageBox.Show(LocationObj... MessageBox.Show(LocationObj... End Sub The IPLocation Class: Imports System.Xml Public Class IPLocation ......
The following code shows the guts of an ASPX page that will return a KML file that will load in Google Earth. We use an XmlTextWriter to write an XML file to the response stream. We set the ContentType = "application/vnd.google-ear... so it will automatically open in Google Earth if the user has it installed. The page accepts 3 query strings.lat - latitude of geographic pointlon - longitude of geographic pointicon - url of icon that will plot the point If query strings are not provided, ......
This code shows how to use an ASPX page to render RSS with embedded GeoRSS tags. It calls from the FeedMap service. I talk more about the functionality in this blog post. Imports System.Xml Partial Class FeedMap Inherits System.Web.UI.Page Dim place As String = "" Dim lat As Double = 0 Dim lon As Double = 0 Dim count As Integer = 50 Dim rssUrl As String = "" Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Try place = Request.QueryString("place") Catch ......
Too many Google Maps mashups force the user to enter a zip code, or select a state before displaying the data to the user. This interrupts the user experience and takes away the "browsing" capabilities that Google Maps offers. This JavaScript code will show how load data from XML using the Google Maps AJAX helper when the user moves the map and display only the points that are in the viewing range of the user. The XML file is located here. And a working example is here. <script type="text/javascript&... ......
This article is from a talk I did for the Kansas City .net user group. It will show you how to use the AJAX.net library written by Michael Schwarz. Initial Setup: 1) Download dll from http://ajaxpro.info 2) Open Visual Studio and create a new web application 3) Add a reference to the AJAX.net dll 4) Modify your web.config to include: <system.web> <httpHandlers> <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandler... Ajax"/> </httpHandlers> ......
Class to implement manual updates in ClickOnce applications. With one line of code, you can asynchronously update your applications Dim updateCO As New UpdateClickOnce("EnGraph Manager", True, True) Public Class UpdateClickOnce #Region " Variables " Dim WithEvents MyApp As Deployment.Application.Appl... Dim AppName As String = "this application" Dim UseMsgbox As Boolean = True Dim IsChecking As Boolean = False #End Region #Region " Properties " ......