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

M

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!!!
 
M

Mark Rae [MVP]

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top