Search This Blog

Monday, May 21, 2012

C# MVC3 Razor


I've been onto razor lately, and I must admit I am new to this approach. Using the tutorial working with data set I wanted to populate the data from database to the table with alternating row style applied. The output would be same as below. Doing it manually is quite easy. But, what if our data is coming from the database? How can we achieve this? There are quite a number of ways to achieved it view it here. But I wanted to have a simple approach and that is using CSS. Fortunately we can do it in pure CSS
            #customers tr.alt:nth-child(even) td
            {
            color:#000000;
            background-color:#EAF2D3;
            }
 Modifying the code in tutorial  with code below we can attain our objective of having alternating row style in table.

<style type="text/css">
            #customers
            {
            font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
            width:100%;
            border-collapse:collapse;
            }
            #customers td, #customers th
            {
            font-size:1em;
            border:1px solid #98bf21;
            padding:3px 7px 2px 7px;
            }
            #customers th
            {
            font-size:1.1em;
            text-align:left;
            padding-top:5px;
            padding-bottom:4px;
            background-color:#A7C942;
            color:#ffffff;
            }
            #customers tr.alt:nth-child(even) td
            {
            color:#000000;
            background-color:#EAF2D3;
            }
</style>

<body>
        <a href="~/InsertProducts">Insert Products</a>
        <a href="~/EditProducts">Edit Products</a>
        <a href="~/ListProductsForDelete">Delete Products</a>
        <h1>Small Bakery Products</h1>
        <table id ="customers">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Product</th> 
                    <th >Description</th>
                    <th >Product Description</th>
                    <th>Price</th>
                </tr>    
            </thead>
            <tbody>
                @foreach(var row in db.Query(selectQueryString)){
                <tr class="alt">
                    <td><a href="@Href("~/UpdateProducts", row.Id)">Edit</a></td>
                    <td><a href="@Href("~/DeleteProduct", row.Id)">Delete</a></td>
                    <td>@row.Name</td>
                    <td>@row.Description</td>
                    <td>@row.Price</td>
                </tr>
                }
            </tbody>
        </table>     
        <br />
</body>


 ID Product Product Description Prices
1 Carrot Cake A scrumptious mini-carrot cake encrusted with sliced almonds 8.99
2 Lemon Tart A delicious lemon tart with fresh meringue cooked to perfection 9.99
3 Cupcakes Delectable vanilla and chocolate cupcakes 5.99
4 Bread Fresh baked French-style bread 1.49
5 Pear Tart A glazed pear tart topped with sliced almonds and a dash of cinnamon 5.99
6 Chocolate Cake Rich chocolate frosting cover this chocolate lover’s dream. 8.99
7


8


9


10


Wednesday, May 16, 2012

Google Chrome vs IE and Firefox

Nerd Stats in chrome.
I've been a fan of chrome browser since its birth. But my default web browser is firefox. The one thing that I don't like about my default browser is - its always crashed. Today, we are going to do a simply test on memory usage.  As you can see in the image IE has the least memory usage. Firefox has top the list.

Sunday, May 6, 2012

Ping Returns General Failure


GENERAL FAILURE
I recently experienced a ping “General Failure” on certain IP address. Previously, the PC I’m using is not enrolled to Active Directory and I can received a reply when trying to ping the IP. However, when IT support enrolled the PC I’m using to the Active Directory Server I now receiving “General Failure”.
I scrutinized Resultant set of Policy by running the rsop.msc in the command line and found out that our network administrator had just filtered and blocked outbound data to the IP.
Solution: I just simply delete DSIPSECPolicyName and DSIPSECPolicyPath keys in computer\hkey_local_Machine\software\policies\microsoft\windows\IPSEC\GPTIPSecPolicy by running regedit in the command line and now I already have reply