473,698 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

custom validator causing postback after error message is displayed

cameokid
10 New Member
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 9633
Frinavale
9,735 Recognized Expert Moderator Expert
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
cameokid
10 New Member
Hey thanks.

Sorry for the late reply.

That is what i had to do. Used "clientValidati onFunction" 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
9283
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 not consistent: (0x0c0001a5). Display.obj : error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c000108). The help for LNK2022 is completely useless:
2
3913
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 javascript checks for things like valid e-mail addresses or phone numbers (without having to add a separate control for validation). One idea I did some work on was having the control implement the IValidator interface and basically recreating...
2
3193
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp The problem I am having is that the data in the custom datagridcolumn is not saved to viewstate and after postback, the column does not contain data.
3
594
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 contains about 5 conditions. The bigest thing is I want to dynamically configure the error message. If I take out the object.ErrorMessage = "TEST" then the control will pick up on the invalid entry but I have no message displayed.
9
3945
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 all three fields matches information in the database. Can you do this in a custom validator?
8
7829
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 VALUE ENTERED BY THE USER EXISTS IN THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED. For this, I used the reference artiicle "http://msdn.microsoft.com/library/default.asp?url=/library/en-...
5
2922
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 Studio.NET 2003 and VB code behind. I have a radio button and textbox, and basically i need the textbox to be required based on the user selecting "Yes" from the radio button. I've read through the newsgroups and found that a Custom Validator
2
1790
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 other validators on the page. I specified the name of the Javascript function with the ClientValidationFunction attribute of the custom validator, and it is being called fine. However, if the validator returns false (ie bad
9
3134
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 lot of research in the areas of XHTML and WAI compliance, and am attempting to come up with a recommendation for our product in terms of standards level compliance. Ideally, I would like to be at XHTML 1.0 Strict. However, in my reading I have...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9166
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.