Click here to Skip to main content
16,016,712 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my application I have two buttons(submit and cancel)
Submit button validates and upload into database.
Cancel button will redirect to another page.

I want to achieve validation only for Submit button.
But validation is happening for cancel button also.

I dont want to do this. Please help me to achieve.

Thanks in advance.
Posted

1 solution

In your Cancel button (html part), include the following
CausesValidation="False"
 
Share this answer
 
Comments
srmohanr 7-Oct-13 5:57am    
Thanks. It's working fine. One more help please.
I have a html control to browse, on the same file.

<input type="file" id="filename" runat="server" name="filename" size="50" required />

Here, when I press Cancel button it's showing validation error msg. How to achieve this
using asp.net in
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" CssClass="cancel-button" onclick="btnCancel_Click" />
Ryan Zahra 7-Oct-13 6:02am    
Why aren't you using a FileUpload control?
<asp:FileUpload ID="FileUpload1" runat="server" />
VICK 7-Oct-13 6:41am    
Dear if you want to use asp file upload control than you can use regular expression along with that to restrict user for specific type of files...If you need further help.
You should post this as new quick question to get the answer.
srmohanr 7-Oct-13 7:18am    
Thanks buddy. I got my requirement using regular expression.
VICK 7-Oct-13 7:20am    
Gud to hear that ur prblm got solved..

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