Cannot get the command event to work... please help

Cannot get the command event to work... please help

am 11.01.2008 20:13:03 von M. Ali Qureshi

Hi Experts,

I am trying to add some linkbuttons dynamically with Command eventhandler.
But this event just does not get fired when i click on the button. See
following:

Function GetLink(ByVal Folder As Boolean, ByVal LinkText As String,
ByVal FolderPath As String) As LinkButton
Dim EditUrl As New LinkButton
EditUrl.Text = LinkText
EditUrl.CommandName = "FolderLink"
EditUrl.CommandArgument = FolderPath
AddHandler EditUrl.Command, AddressOf LinkClick
Return EditUrl
End Function

Protected Sub LinkClick(ByVal sender As Object, ByVal e As
CommandEventArgs)
If e.CommandName.CompareTo("FolderLink") = "0" Then
Response.Redirect("EditNav.aspx?NavID=" &
e.CommandArgument.ToString())
End If
End Sub

The code "LinkClick" does not get fired when i click on the linkbuttons.
Pleaes help... its killing me!!!

Re: Cannot get the command event to work... please help

am 11.01.2008 20:40:28 von mark

"M. Ali Qureshi" wrote in message
news:2D9DDEF3-92F0-44A3-8442-E817C0242159@microsoft.com...

> The code "LinkClick" does not get fired when i click on the linkbuttons.

If you're calling GetLink during Page_Load, that's too late in the page
lifecycle - move it into Page_Init or Page_PreInit instead...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net