Math.random();
Monday, February 9, 2015
Thursday, February 5, 2015
asp.net serialized object in json
//Group data
var lstGroupedPMs = (from lstPMItem in lstPMItemsDetails
group lstPMItem by lstPMItem.KRAType
into KRAMasterGroups
select new
{
KRAType = KRAMasterGroups.Key,
kraGroup = KRAMasterGroups,
templateName = performancetemplatedata.TemplateName,
positionID = performancetemplatedata.PositionID,
designation = performancetemplatedata.Designation
});
json = JsonConvert.SerializeObject(lstGroupedPMs, Newtonsoft.Json.Formatting.Indented);
jObject = JObject.Parse("{\"data\": " + json + "}");
var lstGroupedPMs = (from lstPMItem in lstPMItemsDetails
group lstPMItem by lstPMItem.KRAType
into KRAMasterGroups
select new
{
KRAType = KRAMasterGroups.Key,
kraGroup = KRAMasterGroups,
templateName = performancetemplatedata.TemplateName,
positionID = performancetemplatedata.PositionID,
designation = performancetemplatedata.Designation
});
json = JsonConvert.SerializeObject(lstGroupedPMs, Newtonsoft.Json.Formatting.Indented);
jObject = JObject.Parse("{\"data\": " + json + "}");
asp.net get list of items from listitemcollection
List<CustomEntities.KRAMasterDetails> lstPMItemsDetails =
(from oKRAMasterItem in oPMItems.AsEnumerable()
select new CustomEntities.KRAMasterDetails
{
KRAName = null == oKRAMasterItem[Constant.KRAMaster.KRAName.ToString()] ? string.Empty :
oKRAMasterItem[Constant.KRAMaster.KRAName.ToString()].ToString(),
//added by shekhar 4/2/2015
KRADescription = null == oKRAMasterItem[Constant.KRAMaster.KRADescription.ToString()] ? string.Empty :
oKRAMasterItem[Constant.KRAMaster.KRADescription.ToString()].ToString(),
KRAMeasuringCriteria = null == oKRAMasterItem[Constant.KRAMaster.KRAMeasuringCriteria.ToString()] ? string.Empty :
oKRAMasterItem[Constant.KRAMaster.KRAMeasuringCriteria.ToString()].ToString(),
//End of added by shekhar 4/2/2015
KRAType = null == oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] ? string.Empty :
(oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] as FieldLookupValue).LookupValue,
KRASubType = null == oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] ? string.Empty :
(oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] as FieldLookupValue).LookupValue,
//Updated by shekhar/vikas 3/2/2015
KRATypeID = null == oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] ? 0 :
(oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] as FieldLookupValue).LookupId,
KRASubTypeID = null == oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] ? 0 :
(oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] as FieldLookupValue).LookupId
}).ToList();
(from oKRAMasterItem in oPMItems.AsEnumerable()
select new CustomEntities.KRAMasterDetails
{
KRAName = null == oKRAMasterItem[Constant.KRAMaster.KRAName.ToString()] ? string.Empty :
oKRAMasterItem[Constant.KRAMaster.KRAName.ToString()].ToString(),
//added by shekhar 4/2/2015
KRADescription = null == oKRAMasterItem[Constant.KRAMaster.KRADescription.ToString()] ? string.Empty :
oKRAMasterItem[Constant.KRAMaster.KRADescription.ToString()].ToString(),
KRAMeasuringCriteria = null == oKRAMasterItem[Constant.KRAMaster.KRAMeasuringCriteria.ToString()] ? string.Empty :
oKRAMasterItem[Constant.KRAMaster.KRAMeasuringCriteria.ToString()].ToString(),
//End of added by shekhar 4/2/2015
KRAType = null == oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] ? string.Empty :
(oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] as FieldLookupValue).LookupValue,
KRASubType = null == oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] ? string.Empty :
(oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] as FieldLookupValue).LookupValue,
//Updated by shekhar/vikas 3/2/2015
KRATypeID = null == oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] ? 0 :
(oKRAMasterItem[Constant.KRAMaster.KRAType.ToString()] as FieldLookupValue).LookupId,
KRASubTypeID = null == oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] ? 0 :
(oKRAMasterItem[Constant.KRAMaster.KRASubType.ToString()] as FieldLookupValue).LookupId
}).ToList();
asp.net get item from listitemcollection
performancetemplatedata.TemplateName = (oPMDataItems[0][Constant.PerformanceTemplateData.TemplateName.ToString()]).ToString();
performancetemplatedata.Designation = (oPMDataItems[0][Constant.PerformanceTemplateData.PositionID.ToString()] as FieldLookupValue).LookupValue;
performancetemplatedata.PositionID = (oPMDataItems[0][Constant.PerformanceTemplateData.PositionID.ToString()] as FieldLookupValue).LookupId;
performancetemplatedata.Designation = (oPMDataItems[0][Constant.PerformanceTemplateData.PositionID.ToString()] as FieldLookupValue).LookupValue;
performancetemplatedata.PositionID = (oPMDataItems[0][Constant.PerformanceTemplateData.PositionID.ToString()] as FieldLookupValue).LookupId;
Tuesday, February 3, 2015
Javascript Table of Factorials
<!-- This example is from the book _JavaScript: The Definitive Guide_. --> <!-- Written by David Flanagan. Copyright (c) 1996 O'Reilly & Associates. --> <!-- This example is provided WITHOUT WARRANTY either expressed or implied.--> <!-- You may study, use, modify, and distribute it for any purpose. --> <HTML> <BODY> <SCRIPT LANGUAGE="JavaScript"> document.write("<h2>Table of Factorials</h2>"); for(i = 1, fact = 1; i < 10; i++, fact *= i) { document.write(i + "! = " + fact); document.write("<br>"); } </SCRIPT> </BODY> </HTML>
Simple Switch Case JavaScript Program (for beginners)
<html>
<head>
<script type="text/javascript">
var n=prompt("Enter a number between 1 and 7");
switch (n)
{
case (n="1"):
document.write("Sunday");
break;
case (n="2"):
document.write("Monday");
break;
case (n="3"):
document.write("Tuesday");
break;
case (n="4"):
document.write("Wednesday");
break;
case (n="5"):
document.write("Thursday");
break;
case (n="6"):
document.write("Friday");
break;
case (n="7"):
document.write("Saturday");
break;
default:
document.write("Invalid Weekday");
break
}
</script>
</head>
</html>
<head>
<script type="text/javascript">
var n=prompt("Enter a number between 1 and 7");
switch (n)
{
case (n="1"):
document.write("Sunday");
break;
case (n="2"):
document.write("Monday");
break;
case (n="3"):
document.write("Tuesday");
break;
case (n="4"):
document.write("Wednesday");
break;
case (n="5"):
document.write("Thursday");
break;
case (n="6"):
document.write("Friday");
break;
case (n="7"):
document.write("Saturday");
break;
default:
document.write("Invalid Weekday");
break
}
</script>
</head>
</html>
Check Odd/Even Numbers JavaScript Program (for beginners)
<html>
<head>
<script type="text/javascript">
var n = prompt("Enter a number to find odd or even", "Type your number here");
n = parseInt(n);
if (isNaN(n))
{
alert("Please Enter a Number");
}
else if (n == 0)
{
alert("The number is zero");
}
else if (n%2)
{
alert("The number is odd");
}
else
{
alert("The number is even");
}
</script>
</head>
<body>
</body>
</html>
<head>
<script type="text/javascript">
var n = prompt("Enter a number to find odd or even", "Type your number here");
n = parseInt(n);
if (isNaN(n))
{
alert("Please Enter a Number");
}
else if (n == 0)
{
alert("The number is zero");
}
else if (n%2)
{
alert("The number is odd");
}
else
{
alert("The number is even");
}
</script>
</head>
<body>
</body>
</html>
Subscribe to:
Posts (Atom)