Private: MY Note

Every thing you imagine, study it – know it – use it

My blog moved to http://dev.kratik.net

Please visited my new blog at http://dev.kratik.net

October 25, 2009 Posted by dev1 | OTHER | | No Comments Yet

ASP.NET – Working with Gridview TemplateFields

1. code behide
public string ComputeSeniorityLevel(TimeSpan ts)
{
int numberOfDaysOnTheJob = ts.Days;
if (numberOfDaysOnTheJob >= 0 && numberOfDaysOnTheJob <= 1000) return “Newbie”; else if (numberOfDaysOnTheJob > 1000 && numberOfDaysOnTheJob <= 4000) return “Associate”; else if (numberOfDaysOnTheJob >= 4000 && numberOfDaysOnTheJob <= 8000)
return “One of the Regulars”;
else
return “An Ol’ Fogey”;
}

2. html

<asp:GridView ID="GridView1" Runat="server"
    DataSourceID="employeeDataSource" AutoGenerateColumns="False"
    BorderWidth="1px" BackColor="White" GridLines="Vertical"
    CellPadding="4" BorderStyle="None"
    BorderColor="#DEDFDE" ForeColor="Black">
    <FooterStyle BackColor="#CCCC99"></FooterStyle>
    <PagerStyle ForeColor="Black" HorizontalAlign="Right"
       BackColor="#F7F7DE"></PagerStyle>
    <HeaderStyle ForeColor="White" Font-Bold="True"
       BackColor="#6B696B"></HeaderStyle>
    <AlternatingRowStyle BackColor="White"></AlternatingRowStyle>
    <Columns>
        <asp:BoundField HeaderText="Last" DataField="LastName"
           SortExpression="LastName"></asp:BoundField>
        <asp:BoundField HeaderText="First" DataField="FirstName"
           SortExpression="FirstName"></asp:BoundField>
        <asp:BoundField HeaderText="Hire Date" DataField="HireDate"
           SortExpression="HireDate"
            DataFormatString="{0:d}"></asp:BoundField>
        <asp:TemplateField HeaderText="Seniority">
            <ItemTemplate>
                <%# ComputeSeniorityLevel(DateTime.Now –
                     (DateTime)Eval("HireDate")) %>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <SelectedRowStyle ForeColor="White" Font-Bold="True"
         BackColor="#CE5D5A"></SelectedRowStyle>
    <RowStyle BackColor="#F7F7DE"></RowStyle>
</asp:GridView>

ref: http://msdn.microsoft.com/en-us/library/aa479353(lightweight).aspx

October 20, 2009 Posted by dev1 | ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

Centering: Auto-width Margins

body {
margin
:50px 0px; padding:0px;
text-align
:center;
}

#Content {
width
:500px;
margin
:0px auto;
text-align
:left;
padding
:15px;
border
:1px dashed #333;
background-color
:#eee;
}

October 12, 2009 Posted by dev1 | CSS-xhtml, css | | No Comments Yet

Call webservice from javascript

October 11, 2009 Posted by dev1 | AJAX, ASP.NET, ASP.NET 3.0, ASP.NET 3.5, JAVASCRIPT | | No Comments Yet

How to use HtmlEncode with TemplateFields, Data Binding, and a GridView

Label ID="LabelDescription"
           runat="server"
           Text='<%# System.Web.HttpUtility.HtmlEncode((string)Eval("Description")) %>'

October 9, 2009 Posted by dev1 | ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

Asp.net Permalinks Using URL Rewriting

A Permalink is a permanent link which points to a particular blog entry or forum entry. For example the permalink for this blog article is http://csharp-codesamples.com/2009/03/aspnet-permalinks-using-url-rewriting.

This does not mean that a physical page is created for each blog entry. Instead a single page shows the data for multiple blogs articles dynamically based on some query string.

But all pages in asp.net end with a .aspx extension and if we pass a query string to the page it will look something like Page.aspx?query=test. These links are not very search engine friendly.

This article describes a simple method to create permalinks and improve your asp.net websites search engine optimization using URL rewriting without the use of custom handlers.

ref: http://csharp-codesamples.com/2009/03/aspnet-permalinks-using-url-rewriting/

October 9, 2009 Posted by dev1 | ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

JavaScript dateTime function

October 9, 2009 Posted by dev1 | JAVASCRIPT | | No Comments Yet

FileUpload in UpdatePanel, ASP.NET, like Gmail

http://geekswithblogs.net/ranganh/archive/2009/10/01/fileupload-in-updatepanel-asp.net-like-gmail.aspx

October 7, 2009 Posted by dev1 | ASP.NET, ASP.NET 3.0, ASP.NET 3.5 | | No Comments Yet

asp.net + jquery

Introduction to jQuery in ASP.Net and 10 Advantages to Choose jQuery

http://www.codedigest.com/Articles/ASPNETAJAX/183_Using_JQuery_in_ASPNet_AJAX_Applications_%e2%80%93_Part_1.aspx

More Fun With LINQ – Perform Common Tasks in ASP.NET

http://www.dotnetcurry.com/
http://www.dotnetcurry.com/ShowArticle.aspx?ID=320

October 4, 2009 Posted by dev1 | jQuery | | No Comments Yet

Google Wave จะมาแทน Messenger (เหรอ)

October 4, 2009 Posted by dev1 | OTHER | | No Comments Yet