Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...
Im using a button for in design page and set causes validation=true for validation all controls using validation group. But now button not getting fired in server side. I need to do both validation and server side event....plz guide soon

This is my design code:
VB
<asp:Button ID="btnNext" runat="server" Text="Next Step" SkinID="Button"
                    ValidationGroup="valControls" onclick="btnNext_Click"
                    CausesValidation="False" />



This is my cs code:
C#
protected void btnNext_Click(object sender, EventArgs e)
        {
            ccJoin.ValidateCaptcha(txtCaptcha.Text);
            if (ccJoin.UserValidated)
            {
                lblMsg.Text = "Incorrect code";

            }
            else
            {
                lblMsg.Text = "Code matched";

                }
            return;

}
Posted
Comments
Santhosh Kumar Jayaraman 24-Jul-12 3:06am    
In your code, causesvalidation=false, but you mentioned causes validation=true
Priyaaammu 24-Jul-12 3:08am    
In the beginning i set causes validation=true,but my button not getting fired. So i change to false,then my button event fired. I want to do both button event at server side and validation

Priyaaammu, Your server side validation will automatically get fired when client side validation will become false(As you have use .net validation controls).
Thanks
Ashish
 
Share this answer
 
Comments
Priyaaammu 24-Jul-12 5:30am    
Thanks for your comment...but if causes validation is set to false means button fired and validations are not working,i need both work to do
Hi,

First of all let me tell you one thing that if you are using validation group then all the controls of that group will be validated. If validation is done and result is true then only the server side code will be fire. Check for your controls in that group. If any of the controls is giving error means the server side code will not be fired.

Just remove the validation group from your button. Try this:
VB
<asp:Button ID="btnNext" runat="server" Text="Next Step" SkinID="Button"
onclick="btnNext_Click" CausesValidation="False" />

--Amit
 
Share this answer
 
v2
Comments
Priyaaammu 24-Jul-12 5:30am    
Thanks for your comment...but if causes validation is set to false means button fired and validations are not working,i need both work to do
_Amy 24-Jul-12 5:42am    
See my updated answer..

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