RegisterOnSubmitStatement appear twice

G

Guest

I want to show a confirm message before the gridview delete a record in the
event:
of deleting. I put the following code and it shows the message twice. why?

rotected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
String cskey = "OnSubmitScript";
String scriptText = "return confirm('Are you sure you want to
delete?')";
Type cstype = this.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!(cs.IsOnSubmitStatementRegistered(cstype, cskey)))
{
cs.RegisterOnSubmitStatement(cstype, cskey, scriptText);
}

If the answer is cancel where do I put
e.Cancel = true;

in order to cancel the delete.
Thankyou
 
G

Guest

The JavaScript dialogue box that you are attempting to use as a
decision-making step that allows you to proceed with the delete or not will
pop up on the browser and its returned value (of true of false) should
therefore be used on the browser (not during handling the server-side
GridView.RowDeleting event).

Also you might not want to pop up this confirmation dialogue box OnSubmit,
unless the only function that causes a PostBack on your form is the Delete
function.

For a demo on how to process such a client script take a look at this demo:
http://www.webswapp.com/codesamples/aspnet20/gridview_multiplerows_selection/
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top