Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

I have an GridView with Editable Textboxes. I check values of textbox(Check empty) onblur events. Its works fine.

But what i need is, when i click CANCEL button, it again calls my "Script Alert".

How to disable those alerts on CANCEL button Click??
Posted
Updated 9-Aug-11 3:56am
v3
Comments
rahkan 9-Aug-11 11:54am    
How are you adding the javascript alert to the cancel button in the first place? If you're adding a javascript alert to the cancel but don't want it on the cancel then just don't add it.
J.Karthick 11-Aug-11 1:16am    
Nope....I didn't add any JS for CANCEL...I just add it for my Grid Textboxes.

While i'm in FOCUS of an TEXTBOX, if i click CANCEL button its not execute CANCEL event's code. It just keep on gives me alert that i added for my GRID textboxes.

Hope you understand....what im trying....
BobJanova 9-Aug-11 12:22pm    
Not enough detail ... is this a modal page or a page that pressing 'Cancel' causes navigation away? If so, just disable all events when you press Cancel (a global flag client-side will do for that).
J.Karthick 11-Aug-11 1:18am    
You are the one, understanding my Question.....Thanks for your Solution. Will try it out....

Found one Pretty solution for this Post, it may be not acceptable but its enough for me.

Causing alert and make focus always repeates when even i click CANCEL button. Hence i just stops my alert from JS.

So, its just focusing on the textbox. While i clicking CANCEL, it again focus once and execute the CANCEL server code. In CANCEL event's code i lost my page focus(response.redirect("URL")). Hence it works fine.


Thanks guys for your support...
 
Share this answer
 
Set the EnableValidation property of the button to false
 
Share this answer
 
Comments
J.Karthick 9-Aug-11 9:40am    
I'm not using VALIDATIONS here...I'm using ALERT BOX from JS
[no name] 9-Aug-11 9:49am    
From your question "and made validations."

Don't shout because you haven't explained yourself well enough. Clarify what you are doing and what you want.
J.Karthick 9-Aug-11 9:57am    
I'm just saying....not shouting...
If so...My apologies for that
CausesValidation property determines whether validation must be performed on button click or not, if asp.net validation control are used. It can be either true or false. By default it is true.

To prevent validation to occur on the click of the Cancel button, set the CausesValidation property to false
C#
<asp:Button ID="btnCancel" runat="server" CausesValidation="false" Text="Cancel" />


Let me know your feedback.
 
Share this answer
 
v2
Comments
[no name] 10-Aug-11 10:15am    
Did you even bother to read the other responses?
Monjurul Habib 10-Aug-11 12:17pm    
yes i always do..i think you never bother...is EnableValidation & CausesValidation similar to you.If so then i doubt about your long experience.
J.Karthick 11-Aug-11 1:22am    
Well said....Thats "CAUSEVALIDATION" property...but i didn't use that...Please check my updated question and Comments below my Question.

Thanks for your time on my POST :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900