Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > .NET

Reply
 
LinkBack Thread Tools
Old March 15th, 2007, 05:35 AM   #1
New Member
 

Join Date: Mar 2007
Location: italy
Age: 34
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 darkmage1975 is on a distinguished road
FormView and CustomValidator

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.
darkmage1975 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 29th, 2007, 12:23 PM   #2
New Member
 

Join Date: Mar 2007
Location: California
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 dnhdevelopment is on a distinguished road
Re: FormView and CustomValidator

i dont see where you told it what control to validate. for example in your custom validator:

ControlToValidate="s1a2altroTextBox"

so as a rough example:

Code:
<asp:FormViewID="FormView1"runat="server">
<ItemTemplate>
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
<asp:CustomValidatorID="CustomValidator1"runat="server"ControlToValidate="TextBox1"
ErrorMessage="CustomValidator"></asp:CustomValidator>
</ItemTemplate>
</asp:FormView>

Last edited by karinne; March 30th, 2007 at 11:06 AM.. Reason: Please use [code]...[/code] tags when displaying code!
dnhdevelopment is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old March 29th, 2007, 12:31 PM   #3
New Member
 

Join Date: Mar 2007
Location: California
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 dnhdevelopment is on a distinguished road
Re: FormView and CustomValidator

I see what your trying to do.. but the OnServerValidate="s1a2altroFV" will never get called unless it's attached to something. so it does have to be attached to something. when you assign it's ControlToValidate="" you should also set EnableClientScript="False" to ensure it does not perform this client side.
dnhdevelopment is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
formview customvalidator


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
VWD FormView InsertItemTemplate CustomeEditor CliveMM .NET 0 August 24th, 2007 10:44 AM


Search Engine Optimization by vBSEO 3.2.0 RC8