473,288 Members | 1,726 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,288 software developers and data experts.

CustomValidator doesn;t work

wroten following aspx in VWD 2005

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="TextBox1"
EnableClientScript="False" ErrorMessage="error!"
OnServerValidate="CustomValidator1_ServerValidate" ></asp:CustomValidator><br
/>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" /></div>
</form>
</body>
</html>

code behind .cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
Response.Write("Valid");
}
else
Response.Write("InValid");
}
}
Even the args.isValid always set to "false", Valid is printed you to the page.
I set a breakpoint in "agrs.isValid = false", but the program doesn;t stop
in the line when I click the button, the Server Validation haven't run.

Tried similar code in v1.1 VS2003, but still failed. Does I missed something?

Thanks for help

Jason Chan
May 16 '06 #1
1 1453
You need to set validationEmptytext = true in your CustomValidator control OK!

May 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Mr. x | last post by:
Hello, I have some code as follows. It seems that customValidator doesn't work - because i don't get any message. In the body : <asp:table> <asp:TableRow>
5
by: Gene McCrory | last post by:
Is it possible to have a CustomValidator against two controls in an EditItemTemplate on a DataGrid? Case: Have a business rule that states if ATextBox starts with "ACertainValue" then BTextBox...
3
by: Ronan Dodworth | last post by:
Hi there I'm having a little bit of a problem with my customvalidator control. The problem is the javascript runs fine on my local webserver IIS but not when I post it to the web hosting server....
1
by: SMG | last post by:
Hi All. My forms has two textboxes, 1 username, 2 password. Both has requiredfield validator it works fine when there is no input in these textboxes. And the errorMsg is shown in...
1
by: Vi | last post by:
Hi, I have two pairs of a DropDownList and TextBox Controls and for each pair I have a CustomValidator that makes sure that at least one of the two (DropDownList or TextList) has a value. When I...
1
by: Ricky Williams | last post by:
I have a CustomValidator for a Radio Button that works fine with IE, but doesn't trigger with Firefox or Netscape. I have been stuck on this one for 3 weeks; any suggestions greatly appreciated....
1
by: Beffmans | last post by:
Hi I have defined an customvalidator on my TextBox: function clientvalidate(source, arguments){ { // even number? if (arguments.Value%2 == 0) arguments.IsValid = true; else
1
by: RTT | last post by:
It's my first time i want to write a cotum validator but it doesn't seem to work. In de page i've put this validator: <asp:CustomValidator id="CVFBeginDate"...
3
by: Stan SR | last post by:
Hi, I have a web user control that contains 3 dropdownlists it's a date selector, so one contains the days, one the months and the last the years. Each of them starts with a blank value. I...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.