Wednesday, January 13, 2016

Zebra Striped Tables using jQuery

 $(document).ready(function () {

        $("#agTable tr:nth-child(even)").addClass("alternateRow");
        $("#agTable tr:nth-child(odd)").addClass("normalRow");


});






<style>
   table {
        border-collapse: collapse;
    }
   th{
       font-size: x-small;
   }
    table, td, th {
        border: 1px solid black;
    }

    tr.alternateRow td {
        background: #EEE;
        border-bottom: none;
        border-left: none;
        border-right: 1px solid #CCC;
        border-top: 1px solid #DDD;
        padding: 2px 3px 3px 3px;
    }

    tr.normalRow td {
        background: #FFF;
        border-bottom: none;
        border-left: none;
        border-right: 1px solid #CCC;
        border-top: 1px solid #DDD;
        padding: 2px 3px 3px 3px;
    }


</style>

Scrollable Table with Fixed Headers

Using HTML5, the CSS for this is straight-forward, but the problem is the widths of the cols then get all messed up.

So first make sure to use HTML5 table markup:

<table>
<thead>
<tr>
<th>
<th>
</tr>
</thead>
<tbody>
<tr>
<td>
<td>
</tr>
</tbody>
</table>

Then use the following CSS:

<style>
  table tbody, table thead {
        display: block;
    }

    table tbody {
        overflow: auto;
        height: 200px;
    }
</style>


Tuesday, December 1, 2015

MVC Drop Down Lists and Selects

This is the most concise way to do it:

http://instinctcoder.com/asp-net-mvc-4-dropdownlist-example/




ASP.Net MVC 4 DropDownList Example

1. First of all, we will assume you know how to create a new MVC project in MS 2012, in case you need guide, please refer to here. Please create a project and name itDropDownList.
2. It’s recommended that we bind data with strongly type model, so that we could spot the error in design time. Now create a View Model folder and in this folder add a class name Programming.cs and this class will going to help us to bind data into view. Copy this code into Programming.cs.
3. Create a controller and name it DropDownList. (Right click on Controllers Folder > Add > Controller). Now we need to prepare for dropdownlist data , go to Controller> DropDownListController.cs then add this code into Index function
4. In the DropDownListController.cs, add view with name index. (Right click on ActionResult > Add View). Then go to Views > DropDownList> Index.chtml. Copy code below and paste into Index.chtml