Cancelling linkButton in GridView from javascript

D

David Davis

I have a GridView with a ButtonField column set as ButtonType = Link. I want
to add a client-side script call that would cancel the GridView1_RowCommand
event.

I add the client-side script using the OnClientClick property as follows:

If e.Row.RowType = DataControlRowType.DataRow Then
Dim lnkbtnListBill As LinkButton = _
CType(e.Row.Cells(4).Controls(0), LinkButton)
lnkbtnListBill.OnClientClick =
"javascript:ClearTrackerDialog();"
End If

The resulting html source has the postback in a separate href as follows:

<a onclick="javascript:ClearTrackerDialog();"
href="javascript:__doPostBack('grdResults','ListBillLink$0')">C9101234</a>

I need to somehow combine these so my ClearTrackerDialog() comes in the href
just before the post back script so if it returns false, the post back will
not occur.

Thanks, --David
 
D

David Davis

Ok, just figured it out. I need to add a "return" statement on my javascript
call:

lnkbtnListBill.OnClientClick = "return ClearTrackerDialog();"
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top