Calling C# user-defined function in javascript

G

Guest

Hi! Programmers,,,,,,

Scenario
I have a DataGrid with the delete button, If the user delete the row I'd
like to show a confirmation dialog box with two buttons(Yes,No). If the user
click yes the program must call my user-defined function to delete the row
from database.

The problem is I do not know how to create a confirm on deletes in a datagrid.

Can somebody help?


Thanks
Mpho
 
M

Martin Marinov

Hi there,

you have to do this in two steps:
1. when creating the datagrid, you have to add to Attributes collection of
the button that will call the delete command onclick ( not the server event,
but javascript ) that should contains something like

onclick="return confirmation('Are you really want to do that?');"
when the user click the button this line will popup a confirmation box. if
the user clicks No, then the page will not be submited. if the user clicks
OK the page will submited

2. you have to create a Delete command event or to create ItemCommand event
and check which is the command of the button that was pressed

using this you will know that if the poage is submitted and the .net enters
in the Command event ( Item or Delete ), the user was accepts the
confirmation

Regards
Martin
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top