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>

jQuery Zebra Stripes
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;
    }
}

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;
}

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 :

C#.Net How To: Publish a Web service in IIS using Visual Studio 2010

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");