Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

problem with customvalidator

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff - 18 Mar 2008 16:11 GMT
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:CustomValidator ID="valCustom" ControlToValidate="txt"
OnServerValidate="TestValidate" Display="Dynamic" runat="server"
ErrorMessage="CustomValidator"></asp:CustomValidator>
<asp:ImageButton ID="ibSave" ImageUrl="~/Images/Go.gif"
OnClick="ibSave_method" runat="server" />

protected void TestValidate(object source, ServerValidateEventArgs args)
   {
       // do some processing/
       args.IsValid = false;
   }

any suggestions?
bruce barker - 18 Mar 2008 16:32 GMT
your save code probably does not check IsValid:

if (IsValid)
{
   // do save
}

-- bruce (sqlwork.com)

> hey
>
[quoted text clipped - 24 lines]
>
> any suggestions?
Jeff - 18 Mar 2008 17:04 GMT
thank you

> your save code probably does not check IsValid:
>
[quoted text clipped - 36 lines]
>>
>> any suggestions?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.