undefined check not working in javascript

Checking undefined is not work when we go normal if statement, As like below

var id=$('#txt').val();

if(id != 'undefined')
{
// Our Code
}

"id" is var type, i.e mean unknown type, such as whether "id" is string, numeric, or even undefined.  
if "txt" is not defined in the page, then id's value is  undefined, so we shall check the type of operand with value.

By using "typeof" operator we resolve above issue. The "typeof" operator in JavaScript/Jquery allows you to probe the data type of its operand.

var item = 10;
alert(typeof item); This returns the type of item not value.


if(typeof id != 'undefined')
{
// Our Code


I hope this will help you to resolve the problem.

How to check if a variable is NOT undefined

Checking undefined is not work when we go normal if statement, As like below

var id=$('#txt').val();

if(id != 'undefined')
{
// Our Code
}

"id" is var type, i.e mean unknown type, such as whether "id" is string, numeric, or even undefined.  
if "txt" is not defined in the page, then its value is  undefined is a one of type, so we shall check the type of operand with value.

By using "typeof" operator we resolve above issue. The "typeof" operator in JavaScript/Jquery allows you to probe the data type of its operand.

var item = 10;
alert(typeof item); This returns the type of item not value.


if(typeof id != 'undefined')
{
// Our Code


I hope this will help you to resolve the problem.

What's the main difference between int.Parse() and Convert.ToInt32

string str = "199"

int.Parse(str)

  1. This method converts the string to integer. 
  2. If string variable 'str' is null, then it will throw ArgumentNullException. 
  3. If string 'str' has out of integer ranges, then it will throw OverflowException.
  4. If string 'str' is other than integer value, then it will throw FormatException. 


Convert.ToInt32(str)

  1. This method converts the string to integer. 
  2. If string str is null, then it will return 0 rather than throw ArgumentNullException.
  3. If string str represents out of integer ranges, then it will throw OverflowException. 
  4. If string str is other than integer value, then it will throw FormatException. 


What's the main difference between int.Parse() and Convert.ToInt32

string str = "199"

int.Parse(str)

  • This method converts the string to integer. 
  • If string variable 'str' is null, then it will throw ArgumentNullException. 
  • If string 'str' has out of integer ranges, then it will throw OverflowException.
  • If string 'str' is other than integer value, then it will throw FormatException. 


Convert.ToInt32(str)

  • This method converts the string to integer. 
  • If string str is null, then it will return 0 rather than throw ArgumentNullException.
  • If string str represents out of integer ranges, then it will throw OverflowException. 
  • If string str is other than integer value, then it will throw FormatException. 

find number of days in a month in sql



DECLARE @mydate DATETIME

SET @mydate = '1986/01/21'

SELECT DAY(DATEADD(DAY,-DAY(@mydate),DATEADD(MONTH,1,@mydate))) as DAYSCOUNT


Above query will return number days in a month. Actually it return last date of given month. This is simplest way to get number of days in a given month.


Attribute 'ng-app' is not a valid attribute of element 'html'

This is just a warning. You haven't enabled html5 in your application.That s why you are receiving this validation warnings.

Here i gave solution to rid out from this warnings.

After opened your MS VS, Select Tools->Options ->Text Editor- >HTML->Validation, Choose html5 in list, then restart your project.

If you are not find html5 in the list, you need to install html5, then do above step. Click here to down html5.

Again you are receiving such that warining, then prepend data- to the attribute name (e.g. data-ng-app, the warning lines gets disappear.


$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


HOW YOU DEFINE WEB.CONFIG ? CLICK HERE 2 FIND ANSWER


$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

Element section is not supported in visual studio

You haven't enabled html5 in your application.That s why you are receiving this validation warnings.

Here i gave solution to rid out from this warnings. 

After opened your MS VS, Select Tools->Options ->Text Editor- >HTML->Validation, Choose html5 in list, then restart your project.

If you are not find html5 in the list, you need to install html5, then do above step. Click here to down html5.