Online .NET and PHP Development

Posted in C# Programming, General Web, HTML & CSS, Javascript, JQuery, PHP Programming on September 12th, 2010 by phoenixdigital

Interesting site for developing online without the use of Visual Studio or Zend Studio.

http://www.coderun.com/

Not sure how useful it would be but it’s promising.

Serializing Mail Messages

Posted in C# Programming on July 13th, 2010 by phoenixdigital

Useful classes for serializing mail messages

http://nayyeri.net/how-to-serialize-a-mailmessage
and
http://gopi.codeplex.com/

.NET Execution Order

Posted in C# Programming, VB .Net Programming on June 6th, 2010 by phoenixdigital

When a page is loaded the execution order is


Page_Init(object sender, EventArgs e) {}
Page_Load(object sender, EventArgs e) {}
Page_DataBind(object sender, EventArgs e) {}
Page_PreRender(object sender, EventArgs e) {}
Page_Unload(object sender, EventArgs e) {}

http://support.microsoft.com/kb/305141

Tags:

C# Primitive Types

Posted in C# Programming on June 3rd, 2010 by phoenixdigital

Useful lookup of variable types available in c#

C# Type .Net Framework (System) type Signed? Bytes Occupied Possible Values
sbyte System.Sbyte Yes 1 -128 to 127
short System.Int16 Yes 2 -32768 to 32767
int System.Int32 Yes 4 -2147483648 to 2147483647
long System.Int64 Yes 8 -9223372036854775808 to 9223372036854775807
byte System.Byte No 1 0 to 255
ushort System.Uint16 No 2 0 to 65535
uint System.UInt32 No 4 0 to 4294967295
ulong System.Uint64 No 8 0 to 18446744073709551615
float System.Single Yes 4 Approximately ±1.5 x 10-45 to ±3.4 x 1038 with 7 significant figures
double System.Double Yes 8 Approximately ±5.0 x 10-324 to ±1.7 x 10308 with 15 or 16 significant figures
decimal System.Decimal Yes 12 Approximately ±1.0 x 10-28 to ±7.9 x 1028 with 28 or 29 significant figures
char System.Char N/A 2 Any Unicode character (16 bit)
bool System.Boolean N/A 1 / 2 true or false

Using Delegates and Predicates

Posted in C# Programming on May 19th, 2010 by phoenixdigital


    public new TList<T> FindAll(Predicate<T> match) 
    {
      if (match == null)
        {
          throw new ArgumentNullException("match");
        }

      TList<T> result = new TList<T>();
      foreach (T item in this.Items)
      {
        if (match(item))
        {
          result.Add(item);
        }
      }
      return result;
    }


list.FindAll(delegate(TempAddItem t) { return t.ShortCode.Trim() == 'Test'; });

Tags: , ,

Adding indentation and headings to .NET DropDownList

Posted in C# Programming, VB .Net Programming on April 21st, 2010 by phoenixdigital

I have been able to add indentation to dropdown boxes to allow for easier user viewing in many languages… until I met .NET. For some reason when adding spaces to the text in a ListItem the spaces are magically removed.

I was wanting to acheive a DropDownList like below.

Also at the end of this post is a way to achieve the unselectable headings in the example above.

Read more »

Tags: , , , , , , ,

Number formatting in c#

Posted in C# Programming on April 13th, 2010 by phoenixdigital

A quick simple note on how to add prepending zeros to a number


int nMaxNumber = 3;
string strValue = string.Format("{0:0000}", nMaxNumber);

strValue will contain 0003

I will add more examples as I need them
Ref: http://blog.stevex.net/string-formatting-in-csharp/

Tags: , ,

C# Date formatting and Parsing

Posted in C# Programming on March 29th, 2010 by phoenixdigital

Here is a post so I can easily find the correct format for dates


// create date time 2008-03-09 16:05:07.123
DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);

String.Format("{0:y yy yyy yyyy}", dt);  // "8 08 008 2008"   year
String.Format("{0:M MM MMM MMMM}", dt);  // "3 03 Mar March"  month
String.Format("{0:d dd ddd dddd}", dt);  // "9 09 Sun Sunday" day
String.Format("{0:h hh H HH}",     dt);  // "4 04 16 16"      hour 12/24
String.Format("{0:m mm}",          dt);  // "5 05"            minute
String.Format("{0:s ss}",          dt);  // "7 07"            second
String.Format("{0:f ff fff ffff}", dt);  // "1 12 123 1230"   sec.fraction
String.Format("{0:F FF FFF FFFF}", dt);  // "1 12 123 123"    without zeroes
String.Format("{0:t tt}",          dt);  // "P PM"            A.M. or P.M.
String.Format("{0:z zz zzz}",      dt);  // "-6 -06 -06:00"   time zone

as well as the way to call TryParseExact


DateTime completedDateEnd;
if (DateTime.TryParseExact(Request["completedDateEnd"], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out completedDateEnd)
{
  // do stuff

}

also remember to add this to the using statements at the top of the page
using System.Globalization;

ref 1
ref 2

Tags: , ,

Testing on multiple IE versions

Posted in C# Programming, JQuery, PHP Programming, VB .Net Programming on February 3rd, 2010 by phoenixdigital

Handy little program to test on the various versions of IE

IE Tester

Sure to cause no end of frustration getting layouts to look the same in all versions.

Tags: , , , ,

HTTP Post from code behind in C#

Posted in C# Programming on January 21st, 2010 by phoenixdigital

Sometimes you may be required to send some data to a remote site from the code behind via HTTP. Generally this can easily be perfomed if the site allows for GET submissions. However sometimes the site will only accept POST submissions.
Read more »

Tags: , , ,