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 / Web Controls / March 2007

Tip: Looking for answers? Try searching our database.

CustomValidator not working with FormView?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
darkmage1975 - 15 Mar 2007 10:47 GMT
Hi to all!
I've got this problem, I'm thinking on it for about 2 days, searching
info on the web ... but nothing.

Here's the problem: I've got a long FormView control that works fine. I
added a lot of RequiredFieldValidator on a lot of fields and all works
fine: when I click the FormView "InsertButton", the page reloads and I
see that all the RequiredFieldValidator worked fine.

But I need to use also a lot of CustomValidator. I tried first the
"client-side" style, using JavaScript functions and it worked ok. But my
web-admin told me I can't use client-side validation: I can't use
JavaScript due to accessibility issues.

Well, this is not a problem! I switched to server-side validation ...
but it doesn't work at all! The server-side function is never called!
Here's the code:

Code:
--------------------
 <asp:FormView ID="fv" runat="server" AllowPaging="True" DataKeyNames="id" DataSourceID="dsMain"
 DefaultMode="Insert" Width="760px">
 ...
 <InsertItemTemplate>
 ...
 <asp:TextBox ID="s1a2altroTextBox" runat="server" Text='<%# Bind("s1a2altro") %>' Enabled="False" Width="400px" MaxLength="100"></asp:TextBox>
 <asp:CustomValidator ID="s1a2altroCV" runat="server" ErrorMessage="CustomValidator" OnServerValidate="s1a2altroFV">Not ok</asp:CustomValidator>
 ...
 <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="GO!"></asp:LinkButton>
 </InsertItemTemplate>
 ...
 </FormView>
--------------------

and here's the Sub:

Code:
--------------------
 Sub s1a2altroFV(ByVal sender As Object, ByVal args As ServerValidateEventArgs)
 Dim t1 As TextBox
 t1 = fv.FindControl("s1a2altroTextBox")
 lblTest.Text = t1.Text
 args.IsValid = False
 End Sub
--------------------

Please help me I need to finish this work for tomorrow! (I hate this
kind of work!) Thank you in advance.
4.9fiero@gmail.com - 30 Mar 2007 21:13 GMT
On Mar 15, 3:47 am, darkmage1975
> Hi to all!
> I've got this problem, I'm thinking on it for about 2 days, searching
[quoted text clipped - 50 lines]
> Posted viahttp://www.codecomments.com
> ------------------------------------------------------------------------

You need a ControlToValidate specified in the CustomValidator.

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.