Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2012, 08:00 PM   PM User | #1
jay4
New to the CF scene

 
Join Date: Jul 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
jay4 is an unknown quantity at this point
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;
}
jay4 is offline   Reply With Quote
Old 07-05-2012, 08:07 PM   PM User | #2
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
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
alykins is offline   Reply With Quote
Users who have thanked alykins for this post:
jay4 (07-05-2012)
Old 07-05-2012, 09:21 PM   PM User | #3
jay4
New to the CF scene

 
Join Date: Jul 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
jay4 is an unknown quantity at this point
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.
jay4 is offline   Reply With Quote
Old 07-06-2012, 12:04 PM   PM User | #4
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
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
alykins is offline   Reply With Quote
Old 07-06-2012, 07:47 PM   PM User | #5
jay4
New to the CF scene

 
Join Date: Jul 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
jay4 is an unknown quantity at this point
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..
jay4 is offline   Reply With Quote
Old 07-06-2012, 08:54 PM   PM User | #6
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
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
alykins is offline   Reply With Quote
Old 07-06-2012, 09:13 PM   PM User | #7
jay4
New to the CF scene

 
Join Date: Jul 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
jay4 is an unknown quantity at this point
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
jay4 is offline   Reply With Quote
Reply

Bookmarks

Tags
errors, postback, submit, validate, validation

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:06 AM.


Advertisement
Log in to turn off these ads.