473,395 Members | 1,631 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

RegisterOnSubmitStatement appear twice

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
--
Anat
Feb 5 '06 #1
1 1790
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/...ows_selection/

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"anat" wrote:
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
--
Anat

Feb 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MrMike | last post by:
I'll try to initially ask this question without posting too much detail. I have an asp.net datagrid that lists each row twice. What could cause this? If you require additional information, please...
0
by: Gandalf | last post by:
If I have a javascript function on my page that I wish to be called immediately before the form is submitted, using Page.RegisterOnSubmitStatement might seem the ideal method to use. However,...
0
by: Thomas Gurath | last post by:
I have some code that reads a file from disk and inserts it into the http response. When the user clicks the file's title linkbutton, the File Download prompt appears twice if they select Open...
0
by: Just Me | last post by:
Some of my controls appear twice in my tool box. One has an icon that looks like gear. the other icon is a rectangle containing 4 squares plus a small rectangle and a blue line at the top....
1
by: Brian Christensen | last post by:
Hi, Due to long periods during postbacks I'm experimenting on having a load screen. Best practice for this I have been unable to find so I hope someone here can point me in the right direction. I...
4
by: APA | last post by:
I have registered a OnSubmit client script using the below statement: ClientScript.RegisterOnSubmitStatement(this.GetType(), Guid.NewGuid().ToString(), "var retVal = validateForm(); return...
1
by: APA | last post by:
Well, I've figured out a way around this mess. I have no idea why it doesn't work the way I think it should but I do know how to get it to work. The scenario is that I have a form that has one...
2
by: APA | last post by:
Why does adding code to the form submit function using the RegisterOnSubmitStatement method prevent the server side event handler for the submit button from firing? This is completely useless. I...
6
by: prashantkuppa | last post by:
Hi, I have a problem while validating form fields . Here Iam explaining i have two text boxs with names in the html file 1 . first name and text box 2. second name and text box 3.submit
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.