Thursday, July 31, 2014
Wednesday, July 30, 2014
jQuery Zebra Stripes
<html>
<head>
<title>jQuery Zebra Stripes</title>
</head>
<script src="http://www.mkyong.com/wp-content/uploads/jQuery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("table tr:nth-child(even)").addClass("striped");
});
</script>
<style type="text/css">
body,td {
font-size: 10pt;
}
table {
background-color: black;
border: 1px black solid;
border-collapse: collapse;
}
th {
border: 1px outset silver;
background-color: maroon;
color: white;
}
tr {
background-color: white;
margin: 1px;
}
tr.striped {
background-color: coral;
}
td {
padding: 1px 8px;
}
</style>
<body>
<table>
<tr>
<th>ID</th>
<th>Fruit</th>
<th>Price</th>
</tr>
<tr>
<td>1</td>
<td>Apple</td>
<td>0.60</td>
</tr>
<tr>
<td>2</td>
<td>Orange</td>
<td>0.50</td>
</tr>
<tr>
<td>3</td>
<td>Banana</td>
<td>0.10</td>
</tr>
<tr>
<td>4</td>
<td>strawberry</td>
<td>0.05</td>
</tr>
<tr>
<td>5</td>
<td>carrot</td>
<td>0.10</td>
</tr>
</table>
</body>
</html></div>
ID | Fruit | Price |
---|---|---|
1 | Apple | 0.60 |
2 | Orange | 0.50 |
3 | Banana | 0.10 |
4 | strawberry | 0.05 |
5 | carrot | 0.10 |
SEPARATE JAVASCRIPT FUNCTIONALITY into a “behavioural layer,”
Never include Javascript events as inline attributes. This practice should be completely wiped from your mind.
<a onclick="doSomething()" href="#">Click!</a>
All Javascript behaviours should be included in external script files and linked to the document with a <script> tag in the head of the page. So, the anchor tag would appear like this:
<a href="backuplink.html" class="doSomething">Click!</a>
And the Javascript inside the myscript.js file would contain something like this:
$('a.doSomething').click(function(){
// Do something here!
alert('You did something, woo hoo!');
});
Monday, July 28, 2014
Test if Internet Explorer is used and get its version number
// use the class
if(Browser.Version() <8) {
// make crazy IE shit
}
var Browser = {
Version: function(){
var version = 999; // we assume a sane browser
if (navigator.appVersion.indexOf("MSIE") != -1)
// bah, IE again, lets downgrade version number
version = parseFloat(navigator.appVersion.split("MSIE")[1]);
return version;
}
}
if(Browser.Version() <8) {
// make crazy IE shit
}
var Browser = {
Version: function(){
var version = 999; // we assume a sane browser
if (navigator.appVersion.indexOf("MSIE") != -1)
// bah, IE again, lets downgrade version number
version = parseFloat(navigator.appVersion.split("MSIE")[1]);
return version;
}
}
Get Elements By Class Name (getElementsByClassName)
function getElementsByClassName(classname, node){
if (!node) {
node = document.getElementsByTagName('body')[0];
}
var a = [], re = new RegExp('\\b' + classname + '\\b');
els = node.getElementsByTagName('*');
for (var i = 0, j = els.length; i < j; i++) {
if (re.test(els[i].className)) {
a.push(els[i]);
}
}
return a;
}
if (!node) {
node = document.getElementsByTagName('body')[0];
}
var a = [], re = new RegExp('\\b' + classname + '\\b');
els = node.getElementsByTagName('*');
for (var i = 0, j = els.length; i < j; i++) {
if (re.test(els[i].className)) {
a.push(els[i]);
}
}
return a;
}
DateTime Picker in Jquery
<!DOCTYPE HTML>
<html lang="en-gb" dir="ltr">
<head>
<base href="http://xdsoft.net/jqplugins/datetimepicker/" />
<script src="/media/widgetkit/js/jquery.js" type="text/javascript"></script>
</head>
<body id="page" class="page bg_texture_0 " data-config='{"twitter":0,"plusone":1,"facebook":1}'>
<link rel="stylesheet" type="text/css" href="/scripts/jquery.datetimepicker.css" />
<script type="text/javascript" src="/scripts/jquery.datetimepicker.js"></script>
<p><input id="_datetimepicker" type="text" value="2014/03/15 05:06" /></p>
<script type="text/javascript">// <![CDATA[
jQuery(function(){jQuery('#_datetimepicker').datetimepicker();});
// ]]></script>
</body>
</html>
Example :
Wednesday, July 23, 2014
Javascript Function To Get Querystring Value
function getQueryStringValue(paramName) {
try {
var params = document.URLUnencoded.split("?")[1].split("&");
var strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == paramName)
return decodeURIComponent(singleParam[1]);
}
}
catch (err)
{ return null; }
}
var id = getQueryStringValue("Id");
try {
var params = document.URLUnencoded.split("?")[1].split("&");
var strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == paramName)
return decodeURIComponent(singleParam[1]);
}
}
catch (err)
{ return null; }
}
var id = getQueryStringValue("Id");
consume rest web service in c#
WebRequest req = WebRequest.Create("url");
string postData = "sessionName=TechJamSessionAtCurologic&fromDate=1-7-2014&toDate=1-7-2014&sessionScheduleId=6";
byte[] send = Encoding.Default.GetBytes(postData);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = send.Length;
Stream sout = req.GetRequestStream();
sout.Write(send, 0, send.Length);
sout.Flush();
sout.Close();
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
string returnvalue = sr.ReadToEnd();
URL Example - http://hostname/Methodname
string postData = "sessionName=TechJamSessionAtCurologic&fromDate=1-7-2014&toDate=1-7-2014&sessionScheduleId=6";
byte[] send = Encoding.Default.GetBytes(postData);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = send.Length;
Stream sout = req.GetRequestStream();
sout.Write(send, 0, send.Length);
sout.Flush();
sout.Close();
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
string returnvalue = sr.ReadToEnd();
URL Example - http://hostname/Methodname
Alert the hostname of the current URL using javascript
<script>
function myFunction() {
alert(location.hostname);
}
</script>
function myFunction() {
alert(location.hostname);
}
</script>
Monday, July 21, 2014
workflow manager tools need to be installed to build - project visual studio 2013 and sharepoint 2013
1) Download the installer from the web and execute it.In the search results, click the “Add” button for the Workflow Manager 1.0 row. Then, click the “Install” button
2) In order to start the installation process, just click the “I accept” button in the wizard.
3) Then check if issue solved else restart computer and then check
2) In order to start the installation process, just click the “I accept” button in the wizard.
3) Then check if issue solved else restart computer and then check
Tuesday, July 15, 2014
how to get json key and value in javascript?
var obj = $.parseJSON('{"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}');
alert(obj['jobtitel']);
//By using javasript json parser
var t = JSON.parse('{"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}');
alert(t['jobtitel'])
loop and get key/value pair for JSON array using jQuery
var result = '{"FirstName":"John","LastName":"Doe","Email":"johndoe@johndoe.com","Phone":"123 dead drive"}';
$.each($.parseJSON(result), function(k, v) {
alert(k + ' is ' + v);
});
$.each($.parseJSON(result), function(k, v) {
alert(k + ' is ' + v);
});
SharePoint 2013 following links could be useful
1)http://blogs.msdn.com/b/amigan/archive/2012/12/10/part-1-why-apps-are-needed-for-sharepoint-2013.aspx
2)http://blogs.msdn.com/b/amigan/archive/2012/12/10/part-2-introduction-to-sharepoint-2013-app-model.aspx
3) https://www.youtube.com/watch?v=xHkGDJmHxYo
4)http://sharepoint.stackexchange.com/questions/54008/how-to-create-apps-for-sharepoint-2013-in-visual-studio-2012
5) http://www.sharepoint-journey.com/
6)http://www.slideshare.net/bramdejager/developing-sharepoint-2013-apps-with-visual-studio-2012-sharepoint-connections-amsterdam-2013-bram-de-jager
7)http://sharepoint-community.net/profiles/blogs/sharepoint-2013-sharepoint-hosted-app-development-colorcalendar
2)http://blogs.msdn.com/b/amigan/archive/2012/12/10/part-2-introduction-to-sharepoint-2013-app-model.aspx
3) https://www.youtube.com/watch?v=xHkGDJmHxYo
4)http://sharepoint.stackexchange.com/questions/54008/how-to-create-apps-for-sharepoint-2013-in-visual-studio-2012
5) http://www.sharepoint-journey.com/
6)http://www.slideshare.net/bramdejager/developing-sharepoint-2013-apps-with-visual-studio-2012-sharepoint-connections-amsterdam-2013-bram-de-jager
7)http://sharepoint-community.net/profiles/blogs/sharepoint-2013-sharepoint-hosted-app-development-colorcalendar
Monday, July 14, 2014
serialize object to JSON format in ASP.NET
1)
public
static
Company GetData()
{
return
new
Company()
{
Title =
"Company Ltd"
,
Employees =
new
List<Employee>()
{
new
Employee(){ Name =
"Mark CEO"
, EmployeeType = EmployeeType.CEO },
new
Employee(){ Name =
"Matija Božičević"
, EmployeeType = EmployeeType.Developer },
new
Employee(){ Name =
"Steve Developer"
, EmployeeType = EmployeeType.Developer}
}
};
}
JavaScriptSerializer().Serialize
// Load object with some sample data
Company company = GetData();
// Pass "company" object for conversion object to JSON string
string
json =
new
System.Web.Script.Serialization.JavaScriptSerializer().Serialize(company);
// Write that JSON to txt file
File.WriteAllText(Environment.CurrentDirectory +
@"\JSON.txt"
, json);
The content of that "JSON.txt" file is following:
{"Title":"Company Ltd","Employees":[{"Name":"Mark CEO","EmployeeType":0},{"Name":"Matija
Božičević","EmployeeType":1},{"Name":"Steve Developer","EmployeeType":1}]}
JavaScriptSerializer().Deserialize
string
json = File.ReadAllText(Environment.CurrentDirectory +
@"\JSON.txt"
);
Company company =
new
System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<Company>(json);
Subscribe to:
Posts (Atom)