Thursday, November 10, 2011

Mix different .Net Framework on Windows 2003 Server

This tutorial is for setting up websites based on .Net Framework 2.0 and 4.0 on windows 2003 server.

Very first thing we should keep in mind that IIS 6.0 application pools do not allow mixed .Net Framework.


Here I am showing pictures for making new application pool in IIS 6.0 and IIS 7.0

IIS 6.0 New application pool dialogue

IIS 7.0 New application pool dialogue
As you can see in IIS 6.0 we do not have option for selecting .Net Framework
Steps to setting up mixed .Net Framework(2.0/4.0) on Windows 2003 ServerStep-1We will create two different application pool. I named them DotNet2Pool and DotNet4Pool you can give any name as per your choice.

Step-2Now assign application pool as per .Net requirement of your website as shown in figure


You can check and set your website .Net Framework requirement as shown in below image.

Please make sure do not use .Net Framework 2.0 application pool on ASP.net 4.0 website and vice-versa.


Thanks!

Wednesday, November 9, 2011

Facebook not showing YouTube videos thumbnails

Hi,

When I putting YouTube video link on my Facebook page. Video thumbnail doesn’t show up on Facebook. Sometimes it shows sometimes not. During my search & research process I got two workarounds


  1. This is a lengthy process but generate thumbnail for my this video
    1. Login Facebook and YouTube
    2. Select video to share and click share button below video
    3. Copy long link, paste in Facebook link
    4. Click on attach and post video
    5. Facebook will not generate thumbnail, delete post
    6. From YouTube this time copy short link
    7. Paste in Facebook and post
    8. Hopefully it will generate thumbnail (it works for me, but not always)
  2. This I got from Google support forum it works for this video
    1. Just add &feature=related In last of YouTube link

Thanks

Tuesday, November 1, 2011

Format numbers with Indian style commas.

In our ERP projects we usually need to display commas in numbers. In most of the format we did not get Indian style commas. So I had developed this class. Its main function is Put_Commas it take string as input and return string with commas.

Public Class ClsCommas
    Public Function Put_Commas(ByVal PassString As String) As String
        Dim IsNegative As Boolean
        Dim DecimalPart As String
        Dim TLen As Long            'Length of String without "-" and "."
        Dim LString As String       'String for Storing Changed String
        '-------
        'Check Must Be Greater than 999
        '------

        If System.Math.Abs(Decimal.Parse(PassString)) <= 999 Then
            Put_Commas = PassString
            Exit Function
        End If

        '-------------
        'Check Negative Values
        '-------------
        If Decimal.Parse(PassString) < 0 Then
            IsNegative = True
            PassString = Right(PassString, Len(PassString) - 1)
        Else
            IsNegative = False
        End If
        '---------
        'Remove Decimal Part
        '---------

        If PassString.Contains(".") Then
            DecimalPart = Right(PassString, Len(PassString) - PassString.IndexOf("."))
            PassString = Left(PassString, InStr(1, PassString, ".") - 1)
        Else
            DecimalPart = ""
        End If
        '-----------------
        TLen = Len(PassString)
        If TLen > 3 Then            'First Time Three Char
            LString = Right(PassString, 3)
            TLen = TLen - 3
            PassString = Left(PassString, Len(PassString) - 3)
        Else
            LString = ""

        End If
        Do While TLen > 2
            LString = Right(PassString, 2) + "," + LString
            TLen = TLen - 2
            PassString = Left(PassString, Len(PassString) - 2)

        Loop
        LString = Trim(PassString) + "," + Trim(LString)
        '--------------
        'Add Decimal Part
        '-------------
        If Trim(DecimalPart) <> "" Then
            If Trim(DecimalPart.Contains(".")) = False Then
                LString = LString + "." + DecimalPart
            Else
                LString = LString + DecimalPart
            End If
            '-------------------------------------------------
        End If
        '-----------
        'Check for Negative
        '-----------
        If IsNegative Then
            LString = "-" + Trim(LString)
        End If
        Put_Commas = LString
    End Function
    Private Function Right(ByVal PassStr As String, ByVal RChar As Integer) As String
        Dim LStr As String
        Try
            LStr = PassStr.Substring(PassStr.Length - RChar, RChar)
            Return LStr
        Catch ex As Exception
            Return PassStr
        End Try
    End Function
    Private Function Left(ByVal PassStr As String, ByVal LChar As Integer) As String
        Dim LStr As String
        Try
            LStr = PassStr.Substring(0, LChar)
            Return LStr
        Catch ex As Exception
            Return PassStr
        End Try
    End Function
End Class

Happy Coding!!
Tariq