Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Event handler problem

How can i dynamically add the event handler for the link button clicking event

This is my source code,But this is not working

Private sub ShowWeek()
dim lnkButton as New LinkButton
lnkButton.ID="Day1"
lnkButton.Text="Date" (For e.g)
AddHadler lnkbutton.Click, Addressof DateChaged
End Sub

This ShowWeek() function is called in the HTML tag like <%=ShowWeek()%>. And i am having Place holder which holds the dynamically created link buttons.

Sub DateChanged(sender as object, e as system.eventArgs)
Response.write("Test control")
End sub

The event datechanged is not calling when i am clicking the link button
[687 byte] By [Hariharan] at [2007-11-11 8:13:39]
# 1 Re: Event handler problem
You must add controls and wire up event handlers before the page is sent to the user's browser. I don't think it's possible to create a dynamic control in response to a click event without doing a postback.
Phil Weber at 2007-11-11 23:13:17 >