You're using the wrong ControlToValidate: ControlToValidate="cqidTextBox" should be "uidTextBox". [edit] either OP updated his previously posted code, or I'm clearly going blind.
I have test the similar scenery but the SetFocusOneError don’t cause an error. You can set break point and debug your code. You can also use FireBug to debug your javascript. Then you will know what has caused the error.
gwhhwgy
Member
11 Points
16 Posts
requiredfieldvalidator cause javascript error
Feb 24, 2012 05:11 AM|LINK
When open the client side sourcecode: the error code location is: WebForm_AutoFocus('cqidTextBox');//]]><body> <form id="form1" runat="server"> <asp:FormView ID="FormView1" runat="server" DataKeyNames="id" DefaultMode="Insert" DataSourceID="SqlDataSource1" EnableModelValidation="True"> <InsertItemTemplate> uid: <asp:TextBox ID="uidTextBox" runat="server" Text='<%# Bind("uid") %>' /> <br /> cqid: <asp:TextBox ID="cqidTextBox" runat="server" Text='<%# Bind("cqid") %>' /> <asp:RequiredFieldValidator ID="RFV1" runat="server" Display="Dynamic" ControlToValidate="cqidTextBox"<asp:Button runat="server" CausesValidation="true" CommandName="Insert" Text="chacha" /> </InsertItemTemplate> </asp:FormView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:nx02dbConnectionString %>" InsertCommand="INSERT INTO [tfhouse_zjs] ([uid], [cqid])" > <InsertParameters> <asp:Parameter Name="uid" Type="Int32" /> <asp:Parameter Name="cqid" Type="Int32" /> </InsertParameters> </asp:SqlDataSource> </form> </body>MetalAsp.Net
All-Star
112101 Points
18246 Posts
Moderator
Re: requiredfieldvalidator cause javascript error
Feb 24, 2012 05:32 AM|LINK
gwhhwgy
Member
11 Points
16 Posts
Re: requiredfieldvalidator cause javascript error
Feb 24, 2012 05:59 AM|LINK
thanks! but I indeed want to validate "cqidTextBox".
I thinks the problem is not relate to this. maybe relate to the setfousonerror?
Richey
Contributor
3816 Points
431 Posts
Re: requiredfieldvalidator cause javascript error
Mar 01, 2012 08:02 AM|LINK
Hi,
I have test the similar scenery but the SetFocusOneError don’t cause an error. You can set break point and debug your code. You can also use FireBug to debug your javascript. Then you will know what has caused the error.
http://getfirebug.com/javascript
gwhhwgy
Member
11 Points
16 Posts
Re: requiredfieldvalidator cause javascript error
Mar 17, 2012 12:07 PM|LINK
thanks!