Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other ASP.NET Posts   Ask New Question  Ask New Question With Power Editor

Need help in asp.net cancel button
Sumit Kumar posted at Saturday, November 07, 2009 2:48 AM

Hi all,

Could somebody pls explain what exactly happen when user press cancel button in the form. I have form with two button Save and Cancel. How to handle cancel button pls somebody help me with simple coding.

 

Thanks,

Sumit

 

Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0
Cancel Button
F Cali provided a rated reply to Sumit Kumar on Saturday, November 07, 2009 10:19 AM

A Cancel button in a form will have the CommandName set to "Cancel" and the CausesValidation set to false.  It is just like any other button with its own CommandName.  On the server side, to know that it is clicked, you can check for the CommandName if it is "Cancel" and you can do whatever you want.

protected void onItemCommand(object sender, FormViewCommandEventArgs fce)
    {
        if (fce.CommandName == "Cancel")
        {
            // do work here
        }
    }

Regards,
SQL Server Helper

Reply    Reply Using Power Editor
How well do you know SQL? Find out with the free test assessment from SQL Server Helper:
http://www.sql-server-helper.com/free-test/default.aspx
  Rank Winnings Points
November 3 $65.00 168
October 0 $0.00 0

re
Web star provided a rated reply to Sumit Kumar on Saturday, November 07, 2009 11:12 AM

it completely depends upon where u use cancel button and in which content....

eg. as u told in a Form use Save and Cancel button , there are cancel button use for reset all control on The form like when u submit a form fill some data in textbox and other control and when u click save button then save data on same page if u fill data in textbox and other control and click on Cancel button then it resent all control value as previous menas all textbox will be blank.

public void Cancel_Click(object sender, System.EventArgs e)
        {

             txtTitle.Text = "";
                    txtAuthor.Text = "";
                    txtISBN.Text = "";
                    txtPublication.Text = "";
                  

         }

or u can also redirect to another page without saving any data then u just redirect to anothher page on click of cancel buttton as follows

public void Cancel_Click(object sender, System.EventArgs e)
        {

            Response.Redirect("parentpage.aspx");      

         }

so it matter where u use Cancel Button and the purpose of that

hope u understand

Reply    Reply Using Power Editor
  Rank Winnings Points
November 5 $55.00 143
October 10 $28.00 94