0

我正在開發SharePoint 2013的提供程序託管應用程序。在那裏我有一個.aspx頁面。在該頁面中,我只使用GridView作爲文本框。
它工作正常,但當我把RequiredFieldValidator裏面的GridView我有一個錯誤。
GridView控件代碼:RequiredFieldValidator在VS2012中無法在GridView中工作

<asp:GridView ID="gv_ans_list" runat="server" AutoGenerateColumns="false"> 
    <Columns> 
     <asp:TemplateField HeaderStyle-CssClass="head"> 
      <ItemTemplate> 
       <asp:TextBox ID="txt_ans" runat="server" Text='<%#Bind("answer") %>'></asp:TextBox> 
       <asp:RequiredFieldValidator ID="Req1" runat="server" ControlToValidate="txt_ans" ValidationGroup="v1" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator> 
      </ItemTemplate> 
      <FooterTemplate> 
       <asp:TextBox ID="txt_ans_foot" runat="server"></asp:TextBox> 
      </FooterTemplate> 
     </asp:TemplateField> 
     <asp:CommandField ShowDeleteButton="true" ButtonType="Image" DeleteImageUrl="~/Images/delete.png" /> 
    </Columns> 
</asp:GridView> 

<asp:LinkButton ID="lnk_add" runat="server" Text="Add more Answers" OnClick="lnk_add_Click" ValidationGroup="v1"></asp:LinkButton> 

錯誤:
This is the error

當我把RequiredFieldValidator才把我得到這個錯誤。
請幫我解決這個問題。

回答

2

嘗試:

<appSettings> 
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" /> 
</appSettings> 

更多信息上ValidationSettings:UnobtrusiveValidationMode

指定ASP.NET如何能全局內置的驗證控件使用不顯眼的JavaScript客戶端驗證邏輯。

類型:UnobtrusiveValidationMode

默認值:無

備註:如果這個鍵值設置爲「無」 [默認],ASP.NET應用程序將使用預4.5行爲(JavaScript的內聯在頁面中)用於客戶端驗證邏輯。如果此關鍵字值設置爲「WebForms」,則ASP.NET將使用HTML5數據屬性和來自添加的腳本引用的延遲JavaScript,以用於客戶端驗證邏輯。

相關問題