Hi Akshay,
When you create the controls, add an event handler that points to the common
routine. Here's a little demo. This is for ASP.NET 2.0.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArg s)
Dim lnkbutton1 As New LinkButton
lnkbutton1.ID = "LinkButton 1"
lnkbutton1.Text = "LinkButton 1"
Dim lnkbutton2 As New LinkButton
lnkbutton2.ID = "LinkButton 2"
lnkbutton2.Text = "LinkButton 2"
Dim lit As New Literal
lit.Text = "<br />"
Dim evnthandler As New _
EventHandler(Ad dressOf Me.LinkButton_H andler)
AddHandler lnkbutton1.Clic k, evnthandler
AddHandler lnkbutton2.Clic k, evnthandler
PlaceHolder1.Co ntrols.Add(lnkb utton1)
PlaceHolder1.Co ntrols.Add(lit)
PlaceHolder1.Co ntrols.Add(lnkb utton2)
End Sub
Protected Sub LinkButton_Hand ler _
(ByVal sender As Object, _
ByVal e As System.EventArg s)
Dim lnkbtn As LinkButton
lnkbtn = sender
Response.Write( lnkbtn.ID)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>LinkButt on_Handler</title>
</head>
<body>
<form id="form1" runat="server">
<asp:placeholde r id="PlaceHolder 1" runat="server"> </asp:placeholder >
</form>
</body>
</html>
"akki" <ak************ *@gmail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
I create link buttons dynamically in the code and give them IDs through
which I can distinguish them.I want to know how to create a single
event handler for all the link buttons that I create The event handler
should also be able to identify which link button was clicked....(I am
using VB as the code behind language). Please reply....