Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Angry PostBack clearing errors!!! help

    when i select the acknowledgement checkbox that has autopostback, all errors on my page is cleared and will allow form submission. it is set to autopostback to enable the submit image button in some cases that i've tested the page has been submitted with errors visible. please help code below.

    -----code on page -----
    <telerik:RadButton ForeColor="white" ID="RegisterCheckBox" OnClick="RegisterCheckBox_CheckedChanged" runat="server" ToggleType="CheckBox" ButtonType="ToggleButton"
    AutoPostBack="true" CausesValidation="true" EnableEventValidation="false" >
    <ToggleStates>
    <telerik:RadButtonToggleState Text="Acknowledgement" />
    <telerik:RadButtonToggleState Text="Acknowledgement" />
    </ToggleStates>
    </telerik:RadButton>

    <asp:ImageButton ImageUrl="images\create_button_grey.png" Visible="false" ID="CreateUserButtonDisable" runat="server"
    onclck="CreateUserButton_Click" />
    <asp:ImageButton ImageUrl="images\create_button.png" Visible="true" ID="CreateUserButton" runat="server"
    onclick="CreateUserButton_Click" />


    -----code behind page-----

    protected void RegisterCheckBox_CheckedChanged(object sender, EventArgs e)
    {
    CreateUserButton.Visible = RegisterCheckBox.Checked;
    CreateUserButtonDisable.Visible = !RegisterCheckBox.Checked;
    CreateUserButton.Enabled = CreateUserButton.Visible;
    CreateUserButtonDisable.Enabled = false;
    }

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,739
    Thanks
    41
    Thanked 191 Times in 190 Posts
    not really clear what the issue is (or at least I am not understanding it)... but you may find luck changing the code behind to this...
    Code:
    protected void RegisterCheckBox_CheckedChanged(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            CreateUserButton.Visible = RegisterCheckBox.Checked;
            CreateUserButtonDisable.Visible = !RegisterCheckBox.Checked;
            CreateUserButton.Enabled = CreateUserButton.Visible;
            CreateUserButtonDisable.Enabled = false;
        }
    }

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • Users who have thanked alykins for this post:

    jay4 (07-05-2012)

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Hey alykins thanks for the reply I've tried it with the !PostBack but the validation in place is still being bypassed after the page is being post back when the checkbox is selected. ive tried it with the causesvalidation property set to both true and false with no success.

  • #4
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,739
    Thanks
    41
    Thanked 191 Times in 190 Posts
    ok- then without any code... make a list of requirements/steps (bc I am not clear on what you are trying to do)... I assume it has a form so it should look like
    1) User enters information on a form
    2) User clicks submit
    3) Page needs to validate information
    4) If it is invalid it needs to blah blah blah

    and so on... I need to know that.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #5
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    ok no problem.

    1) User enters information on a form
    2) User clicks checkbox to acknowledge they have read terms of service and enable submit image button.
    3)page should post back after checkbox is clicked so that the submit image button can enable.
    4) Page needs to validate information. (there is also dynamic validation thrown when there are errors in the field in focus)
    5)if page is invalid throw error message to tell user what is wrong on the page and not allow form to be submitted to database until all errors are corrected.
    6) if valid allow form to be submitted.


    as of right now the errors are being thrown on the page but after the checkbox is clicked and the page is postback all errors have disappeared and will allow submission with the incorrect input into the database.
    Last edited by jay4; 07-06-2012 at 07:51 PM.

  • #6
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,739
    Thanks
    41
    Thanked 191 Times in 190 Posts
    ok- I understand now the problem.
    How are you validating? is it something like below?
    Code:
    private void Page_Load(...){...}
    
    private Bool pageValid(){
    //something to validate... other function calls etc.
    }
    
    protected void btnSubmit_OnClick(object sender, EventArgs e){
    if(pageValid())
    {
       //code to do your submitting, call database, whatever
    }
    else
    {
      //throw all your error messages
    }
    if your validation on the backend is like that- then your client side validation might be broken or validating something you are missing. Try your test scenarios with javascripting turned off... do you get past the errors and submit bad code? Client side validation should be an exact copy of serverside- it just makes it faster bc they don't have to wait for postback.

    Edit: If that still doesn't answer your Q- can you post your code behind without DB conn strings and what not... you can PM me if you'd like. I do not know how much I will be on over the weekend- I might not be able to respond till Monday

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #7
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i do not have a

    private Bool pageValid()
    {
    //something to validate... other function calls etc.
    }

    i can send you the code just incase. so I will pm you thanks


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •