Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 29th, 2006, 06:00 PM
Authorized User
Join Date: Jun 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to rfinks
Default Unable to fire a click event

I'm having trouble with link buttons in a datagrid column template, contained in a dynamically loaded user control. I'm unable to get the controls to respond to click events or command events. They don't seem to be firing. I've also tried regular buttons with the same result.

I've got a feeling this is a page life-cycle issue but haven't been able to find an answer. I know that link buttons generate Java Script for client side events. This is not an issue because I've tested link buttons on a form by themselves and they work. I appears that the form is making a round-trip to the server and then reloading the same form instead of redirecting to a different page, which would have happened if the click-event was executed.

Any insight into this issue would be most appreciated.

Roger Finks
Old August 29th, 2006, 06:19 PM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

Have you stepped through the code?

Are the link buttons in an EditCommandColumn?
If so:
In the datagrid, have you set the OnEditCommand, OnUpdateCommand?

If these are just buttons contained in a datagrid, and you need to wire up some functionality to them, in your case, a redirect you could do something like this:

    Private Sub dgItemBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dgRec.ItemDataBound
        Dim lb As LinkButton
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            lb = CType(e.Item.Cells(0).FindControl("lbDelete"), LinkButton)
            lb.Attributes.Add("onClick", "return getconfirm();")
        End If

    End Sub

Then each link button will trigger the getconfirm function when it is clicked.


"The one language all programmers understand is profanity."
Old September 1st, 2006, 10:26 PM
Authorized User
Join Date: Jun 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to rfinks

Thanks for the reply. You've exposed me to a different way to accomplish this. I've got the ItemDataBound event to fire. Now I have to write the Javascript function to handle it.

Roger Finks

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot get Edit Template event to fire zoltac007 ASP.NET 2.0 Professional 4 February 13th, 2007 03:29 PM
ImageButton wont fire event Moonie112 ASP.NET 1.0 and 1.1 Basics 1 February 11th, 2006 01:01 PM
SelectedIndexChanged Event doesn't fire ddudley3 ASP.NET 2.0 Professional 7 February 6th, 2006 10:47 AM
Can't fire button event more than 1 time goatstudio ASP.NET 2.0 Basics 4 September 22nd, 2004 07:45 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.