Surendra Sharma

Surendra Sharma

Search This Blog

Monday, June 24, 2013

How to avoid postback on ENTER key press in textbox or How to block ENTER key press in textbox

$(document).ready(function() {

    // Block ENTER key in textbox
    $('#txtSearch').keypress(function(event) {
        if ((event.keyCode || event.which) == 13) {
            event.preventDefault();
            return false;
        }
    });

})

Thursday, June 20, 2013

Find checkbox in row of each grid using JQuery

if ($(grd.rows[i]).find("input[id*='chkDatabase']:checkbox").attr('checked') == true) {
grd.rows[i].style.display = '';
}
else
{
grd.rows[i].style.display = 'none';

}

Get value from Textbox and convert it into upper or lower case in Jquery

//Get value from textbox and convert in UPPER case
var searchStr = $('#txtSearch').val().toUpperCase();

//Get value from textbox and convert in lower case

var searchStr = $('#txtSearch').val().toLowerCase();

Friday, June 14, 2013

How to Auto Increment Build/Version Numbers of Visual Studio Project and get in C#

Open "AssemblyInfo.cs"

Version information for an assembly consists of the following four values:

      Major Version
      Minor Version
      Build Number
      Revision

You can specify all the values or you can default the Revision and Build Numbers
by using the '*' as shown below:

Replace line
[assembly: AssemblyVersion("1.0.0.0")]
with
[assembly: AssemblyVersion("1.0.*")]

Remove or comment out below line
[assembly: AssemblyFileVersion("1.0.0.0")]

Here 1.0.0.0 Means [Major].[Minor].[Build].[Revision],

Now you should get new version number after each time you rebuild project.
C# code to get version number

var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Label1.Text = string.Format("v{0}.{1}.{2} ({3})", version.Major, version.Minor, version.Build, version.Revision);

When to change each number?
  • Major number when a core piece of the app is rewritten or reworked.
  • Minor version when a new work order is processed
  • Auto increament or leave the build number at zero,
  • Auto increment the revision number every round of testing

In case of auto increament,

  • Build number is the number of days since Dec 31, 1999. 
  • The Revision number is the number of seconds since midnight, divided by 2.

Wednesday, June 12, 2013

How to configure Sybase IQ

a.       Start installation of “Setup” file iq1540_nc_win32_2
Note: - During installation select License copy as option
b.      Create ODBC DSN connection for Sybase IQ from Control Panel -> All Control Panel Items -> Administrative Tools -> Data Sources(ODBC) -> System DSN -> Click Add Button
                                                               i.      On ODBC tab, specify DataSource name = MyDataSource
                                                             ii.      On Login tab, specify
User=<Any User Name>
                Password=<Any Password>
                Action=Connect to a running database on another computer
                Host=<IP Address>
                Port=<Port number>
                Server=<Server Name>
                Database name=<DB Name>
                                                            iii.      Click on OK , OK
c.       Open Start -> Sybase -> Sybase IQ 15.4 -> Interactive SQL
In ODBC Data Source name, browse ODBC that we have created and click on Connect


d.      You can also access GUI based window of Sybase IQ with same steps from Start -> Sybase -> Sybase IQ 15.4 -> Sybase Central

Steps for accessing TFS

1.       Connect to VPN from Visual Studio from View -> Team Explorer.
2.       Try to access the code base using team foundation. Use the login credentials with domain name like “DomainNameXYZ\UserNameXYZ”. Please follow the following steps
a.       Go to team foundation server. Either through View -> Team explorer OR Tools -> connect to Team foundation server
b.      This will open one window where you can add server
c.       After you clicked on ‘Add Server’ it will open one window where you can add  URL “http://ServerLinkXYZ”

d.      Select any “ProjectXYZ” and map its “Trunk” folder with your local folder like “C:\ProjectXYZ\Code\Trunk”.

Calling base class constructor from derived class Constructor

If you want to call one constructor from another in a class itself, then use this()

If you want to call base class constructor from derived class constructor, then use base().

If you are not calling any base class constructor from derived class, then always base class default constructor will called.

Sample Program:

    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            DerivedClass objDerivedClass = new DerivedClass();
            //Output :  BaseClass - Default constructor
            //          DerivedClass - Default constructor

            DerivedClass objDerivedClass1 = new DerivedClass("PageId1234");
            //Output :  BaseClass - Default constructor
            //          DerivedClass - Default constructor
            //          DerivedClass - Overloaded constructor calling Default constructor using this()

            DerivedClass objDerivedClass2 = new DerivedClass(10800, "Student");
            //Output :  BaseClass - Overloaded constructor
            //          DerivedClass - Overloaded constructor calling base class constructor

            Console.ReadLine();

        }
    }

    public partial class BaseClass
    {
        int tempCommandTimeout = 0;

        /// <summary>
        /// Default constructor
        /// </summary>
        public BaseClass()
        {
           tempCommandTimeout = 300;
           Console.WriteLine("BaseClass - Default constructor");
        }

        /// <summary>
        /// Overloaded constructor to Set Command-timeout
        /// </summary>
        /// <param name="iCommandTimeout"></param>
        public BaseClass(int iCommandTimeout)
        {
            tempCommandTimeout = iCommandTimeout;
            Console.WriteLine("BaseClass - Overloaded constructor");
        }
    }

    public partial class DerivedClass : BaseClass
    {
        string TableName = "";
        string PageID = "";

        /// <summary>
        /// Default constructor
        /// </summary>
        public DerivedClass()
        {
            this.TableName = "Employee";
            Console.WriteLine("DerivedClass - Default constructor");
        }

        /// <summary>
        /// Overloaded constructor calling Default constructor using this()
        /// </summary>
        /// <param name="ePageID"></param>
        public DerivedClass(string ePageID)
            : this()
        {
            PageID = ePageID;
            Console.WriteLine("DerivedClass - Overloaded constructor calling Default constructor using this()");
        }

        /// <summary>
        /// Overloaded constructor calling base class constructor to Set Command-timeout
        /// </summary>
        /// <param name="iCommandTimeout"></param>
        public DerivedClass(int iCommandTimeout, string strTableName)
            : base(iCommandTimeout)
        {

            TableName = strTableName;
            Console.WriteLine("DerivedClass - Overloaded constructor calling base class constructor");
        }
    }