LINQ ASP.Net Tutorial

File: NormalMethod.aspx
<%@ Page Language="C#" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    void Page_Init()
    {
        btn.Click += new EventHandler(btn_Click);
    }
    void btn_Click(object sender, EventArgs e)
    {
        lblResult.Text = DateTime.Now.ToString();
    }



    Normal Method


    
    

            id="btn"
        Text="Go!"
        Runat="server" />
            id="lblResult"
        Runat="server" />
    

    


File: AnonymousMethod.aspx
<%@ Page Language="C#" %>
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    void Page_Init()
    {
        btn.Click += delegate(object sender, EventArgs e){
            lblResult.Text = DateTime.Now.ToString();
        };
    }



    Anonymous Method


    
    

            id="btn"
        Text="Go!"
        Runat="server" />
            id="lblResult"
        Runat="server" />
    

    


File: LambdaExpression.aspx
<%@ Page Language="C#" %>
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    void Page_Init()
    {
        btn.Click += (sender, e) => lblResult.Text = DateTime.Now.ToString();
    }



    Lambda Expressions


    
    

            id="btn"
        Text="Go!"
        Runat="server" />
            id="lblResult"
        Runat="server" />