Lambda Expressions in event handling

Posted by Ddd under LINQ category on | Points: 40 | Views : 2589
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default5 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
//Create a Dynamic Button
Button b = new Button();
b.Text = "hello";
//Use of the Lambda expression

b.Click += (s, z) => Response.Write("good");

//add the Control to the WebForm
//form1 is the id of the WebForm


//when you click the button the message good will be displayed.

Comments or Responses

Login to post response