Link to home
Start Free TrialLog in
Avatar of carled
carledFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to detect clicking of "cancel" link on ASP.NET 2.0 detailsview object. VBScript.

How do I detect user clicking on "cancel" on ASP.NET 2.0 DetailsView object standard "insert/cancel" bar? I'm a classic asp developer and I haven't yet got my head around the new technology for all this!  The DetailsView object has an ID of "AcInsert".  I cannot find any relevant event to attach to in the events list, so I'm stumped...  I presume it'll be something like finding the right eventhandler and looking for AcInsert.cancelClicked() having happened or something like that?

VBScript developer, so no C/C# please!
ASKER CERTIFIED SOLUTION
Avatar of here4u247
here4u247

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of carled

ASKER

Whoa... what's an itemcommand event?
Avatar of carled

ASKER

Forget it - looked it up, now I see!  Easy when you get your head around it, it's just soooooooo different to vanilla asp...  and it does so much of the work for you, i you know how to ask it nicely... :-)
Avatar of here4u247
here4u247

basically, the DetailsView have OnItemCommand event handler which deals with commands/button is fired, so in your details view you need to specify which method will handle this event, i.e.:

    DetailsView ItemCommand Example</h3>
        <asp:DetailsView
           ....
            OnItemCommand="MyDetailsView_ItemCommand"
            ....>

also make sure if you specified the cancel button that it should look something like:

<asp:ButtonField CommandName="Cancel" Text="Cancel" />

Event handelry code:

 Sub MyDetailsView_ItemCommand(ByVal sender As Object, ByVal e As DetailsViewCommandEventArgs)
   
        ' Use the CommandName property to determine which button
        ' was clicked.

        Select Case e.CommandName
            Case "Cancel"
                'Do Something here
                MyDetailsView.EditIndex = -1 'edit mode
        End Select

   End Sub