473,413 Members | 1,731 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

custom validator causing postback after error message is displayed

cameokid
Hi,

I have a table with some form fields. This table is hidden on load. I display it on click of a button.

After i enter values and click button inside this table. It displays the custom validation error inside table (I want the error msg to be displayed inside table) but causes postback and hides the table. How do I stop the postback and display the error message while the table is visible.

The code inside custom validation function is ...
Expand|Select|Wrap|Line Numbers
  1. if (conditon) {
  2. args.IsValid = false;
  3. }
  4. else {
  5. args.IsValid = true;
  6. }
Feb 10 '09 #1
2 9608
Frinavale
9,735 Expert Mod 8TB
Set the style of the server in the button click event to display the table if there is an error.

Expand|Select|Wrap|Line Numbers
  1. if (conditon) {
  2.     args.IsValid = false;
  3.  //I'm assuming something didn't validate in this block
  4.  //here you want to set the style of the table to make sure that it's displayed
  5.  //if you aren't using style to hide the table, then make sure that the table
  6.  //is visible in this block.
  7. }
  8. else {
  9.     args.IsValid = true;
Although validating data on the server is always good practice, have you considered using a Client Side Validator Control to help make sure the data is valid before it's sent to the server?
Feb 11 '09 #2
Hey thanks.

Sorry for the late reply.

That is what i had to do. Used "clientValidationFunction" property. Read somewhere on net that all validators do not cause post back except a custom validator. Hence i tried client validation using Javascript to avoid post back and it worked fine. Below is the JS Function.
Expand|Select|Wrap|Line Numbers
  1. function CustomVal_ClientValidate1(source, args)
  2.     {
  3.         var pcdata = document.getElementById("pinCodeTxt").value;
  4.  
  5.         if (pcdata.match(/\d{6}/))
  6.         {
  7.             args.IsValid = true;
  8.         }
  9.         else
  10.         {
  11.             args.IsValid = false;
  12.         }
  13.  
  14.     }
Mar 16 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Bret Pehrson | last post by:
I've converted a non-trivial C++ library to managed, and get the following unhelpful linker error: Assignment.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are...
2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
3
by: brian | last post by:
I am trying to implement a custom validator Client Side. I have the server side code working fine. I place the below script below the body tag outside the <form> tag. My if statement actually...
9
by: Mike Moore | last post by:
We have 3 fields on our web form that makeup what could be a duplicate entry. We would like to look at these three fields that the user enters and check in the database to see the information in...
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
5
by: Mattyw | last post by:
Hi, I'm relatively new to Web Forms, I have been using Required Field Validators and Regular Expression Validators on a Web Form I am developing and everything works as expected using Visual...
2
by: Alan Silver | last post by:
Hello, I have a custom validator on my page, and have the server-side code working fine. I want to add a client-side funtion as well, but am not sure how to wire it in so that it works with the...
9
by: wardy1975 | last post by:
Hi All, Looking for a little expert advice on a few web standards issues. I am currently trying to understand the impact of web standards for a web application I work with. I have been doing a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.