473,651 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with customvalidator

hey

net 3.5

I have problem with a customvalidator . I enter values into the TextBox named
"txt" and clicks on the save button (ibSave) then the TestValidate method
get triggered. TestValidate set args.IsValid = false and the customvalidator
displays an error on the webpage. The problem is that when I check in the
database, the value has still been added to the database. if the value
entered in the TextBox is not a correct value, then I want it not store it
in the database...

below are my markup and code-behind

<asp:TextBox ID="txt" runat="server"> </asp:TextBox>
<asp:CustomVali dator ID="valCustom" ControlToValida te="txt"
OnServerValidat e="TestValidate " Display="Dynami c" runat="server"
ErrorMessage="C ustomValidator" ></asp:CustomValid ator>
<asp:ImageButto n ID="ibSave" ImageUrl="~/Images/Go.gif"
OnClick="ibSave _method" runat="server" />

protected void TestValidate(ob ject source, ServerValidateE ventArgs args)
{
// do some processing/
args.IsValid = false;
}
any suggestions?
Mar 18 '08 #1
2 1956
your save code probably does not check IsValid:

if (IsValid)
{
// do save
}

-- bruce (sqlwork.com)
"Jeff" wrote:
hey

net 3.5

I have problem with a customvalidator . I enter values into the TextBox named
"txt" and clicks on the save button (ibSave) then the TestValidate method
get triggered. TestValidate set args.IsValid = false and the customvalidator
displays an error on the webpage. The problem is that when I check in the
database, the value has still been added to the database. if the value
entered in the TextBox is not a correct value, then I want it not store it
in the database...

below are my markup and code-behind

<asp:TextBox ID="txt" runat="server"> </asp:TextBox>
<asp:CustomVali dator ID="valCustom" ControlToValida te="txt"
OnServerValidat e="TestValidate " Display="Dynami c" runat="server"
ErrorMessage="C ustomValidator" ></asp:CustomValid ator>
<asp:ImageButto n ID="ibSave" ImageUrl="~/Images/Go.gif"
OnClick="ibSave _method" runat="server" />

protected void TestValidate(ob ject source, ServerValidateE ventArgs args)
{
// do some processing/
args.IsValid = false;
}
any suggestions?
Mar 18 '08 #2
thank you
"bruce barker" <br*********@di scussions.micro soft.comwrote in message
news:41******** *************** ***********@mic rosoft.com...
your save code probably does not check IsValid:

if (IsValid)
{
// do save
}

-- bruce (sqlwork.com)
"Jeff" wrote:
>hey

net 3.5

I have problem with a customvalidator . I enter values into the TextBox
named
"txt" and clicks on the save button (ibSave) then the TestValidate method
get triggered. TestValidate set args.IsValid = false and the
customvalidato r
displays an error on the webpage. The problem is that when I check in the
database, the value has still been added to the database. if the value
entered in the TextBox is not a correct value, then I want it not store
it
in the database...

below are my markup and code-behind

<asp:TextBox ID="txt" runat="server"> </asp:TextBox>
<asp:CustomVal idator ID="valCustom" ControlToValida te="txt"
OnServerValida te="TestValidat e" Display="Dynami c" runat="server"
ErrorMessage=" CustomValidator "></asp:CustomValid ator>
<asp:ImageButt on ID="ibSave" ImageUrl="~/Images/Go.gif"
OnClick="ibSav e_method" runat="server" />

protected void TestValidate(ob ject source, ServerValidateE ventArgs args)
{
// do some processing/
args.IsValid = false;
}
any suggestions?

Mar 18 '08 #3

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

Similar topics

1
2014
by: bill yeager | last post by:
I'm using the customvalidator in my web page. I get the following error when I try to run the web page: Unable to find control id 'lstRider' referenced by the 'ControlToValidate' property of 'cvRiders'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
3
1849
by: philipl | last post by:
hi, i have a textbox in my edititemtemplate in my datagrid. I have created a customvalidator for it, when i update the row the appropiate function gets called to customvalidate but the problem is that the error message in my customvalidator does not get printed in the datagrid even though I have set the isvalid property in the server function to false. Does anyone know why this is? Here is the code snippets:
10
3077
by: Brian Henry | last post by:
Hi, I am having a problem with an attachment system I made... it works with files up to ~3MB in size then after that if you try to upload a file it just goes to a "Page can not be displayed" page like it tried to do it but errored... I thought changeing the max size for the file input box to about 100mb would fix it but nope here is my page code and my code behind code... ===============
1
1824
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 ValidationSummary. Now I want to check the username should contain only chatacters, ( I want to use customvalidator), when i enter char+number it trap the event of customvalidator but it doesn't show the errormsg in the customValidator and submits the form.
0
3535
by: ghafranabbas | last post by:
This is how you use the customvalidator control in any INamingContainer interface control (Datagrid, DataList, DataRepeater, etc). 1. In the ItemTemplate, place your customvalidator 2. Set the OnServerValidate property of the customvalidator 3. Get reference to the Data Item object (For DataList is DataListItem, for DataGrid its DataGridItem) 4. Get reference to any controls needed for validation 5. Perform the validation
1
1498
by: Nathan Sokalski | last post by:
I want to make sure that the SelectedDate property of the Calendar control is later than the current date or that a certain checkbox is selected. I tried to use a CustomValidator control with the following code: Private Sub validTimeFrame_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles validTimeFrame.ServerValidate If chkUnknown.Checked OrElse...
0
1264
by: antonyliu2002 | last post by:
The full code is pasted below. It looks scarily long, but it's pretty simple. It is adapted from a sample code at MSDN. If you run it, and check it out from your browser, you'll see: CustomValidator ServerValidate Example Enter an even number: Zip:
0
2172
by: bauer.todd | last post by:
The following page works fine on FireFox (the custom validator checks to make sure that there's a value in the file upload text box). However, on IE 7, when there's a value in the text box, the page doesn't post-back when clicking submit. Can anyone reproduce or offer some advice? ASPX file <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
2
1334
by: testemailsystem.test | last post by:
Hi everyone, I use CustomValidator with the server event onservervalidate (no javascript event). The scenario : The user filled the form and pressed SUBMIT. But because there was an error – the error message of the CustomValidator was shown. The user fixed the error and pressed SUBMIT – this time he is transferred to the second page.
0
8347
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
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
8792
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...
1
8457
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
8571
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
4280
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
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
1
1905
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
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.