我有一个ListBox,它同时包含RequriedFieldValidator和ListSearchExtender。但每当我更改ListBox的选择并单击页面中的任何位置时,都会发生JavaScript错误。抛出错误的函数是ValidatorOnChange,事件为null。这只发生在IE9上。如果我打开兼容性视图,则错误消失。有没有人有同样的问题?以下是我的代码:
<tr>
<td class="greenback">
</td>
<td>
Product <span class="littlefont">*</span>
<asp:RequiredFieldValidator id="RequiredFieldValidator10"
ControlToValidate="productNamesListBox"
Text="Required Field!"
runat="server" CssClass="warning" ValidationGroup="formValidation"/>
</td>
<td>
<asp:ListBox ID="productNamesListBox" runat="server"
DataSourceID="productNamesSqlDataSource" DataTextField="ProductName" CssClass="listboxes"
DataValueField="ProductID" Rows="1"
ondatabound="productNamesListBox_DataBound"></asp:ListBox>
<asp:ListSearchExtender ID="productNamesListBox_ListSearchExtender"
runat="server" Enabled="True" TargetControlID="productNamesListBox">
</asp:ListSearchExtender>
<asp:SqlDataSource ID="productNamesSqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:SPRConnectionString %>"
SelectCommand="SELECT productID, ProductName FROM [spr2].[dbo].[sprProducts] ORDER by ProductName">
</asp:SqlDataSource>
</td>
</tr>
答案 0 :(得分:0)
听起来你有自己的错误组合。 最简单的方法是在服务器端验证。 这可能代价高昂,希望您的服务器足够强大。