Click here to Skip to main content
13,797,212 members
Rate this:
 
Please Sign up or sign in to vote.
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:
<asp:Button ID="btnNext" runat="server" Text="Next Step" SkinID="Button"
                    ValidationGroup="valControls" onclick="btnNext_Click"
                    CausesValidation="False" />



This is my cs code:
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 23-Jul-12 21:48pm
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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:
<asp:Button ID="btnNext" runat="server" Text="Next Step" SkinID="Button"
onclick="btnNext_Click" CausesValidation="False" />

--Amit
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.181207.3 | Last Updated 24 Jul 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100