0

I am using a theme on a ASP.Net Webforms project that contains and loads bootstrap/jQuery 1.11 / jQuery UI libraries on the master page. I am using different plugins like jQuery Datatables & AppendGrid for some data display purpose. I am facing a weird problem on the pages where if I add a RequiredFieldValidator control to any of the controls, the browser says "dataTables is not a function" or "appendGrid is not a function". Both libraries start working as soon as I remove the RequiredFieldValidator control from the page. The issue can be replicated on a master page as well as a control page.

Code present in head tag

<asp:PlaceHolder runat="server">
    <script type="text/javascript" src="/bundles/themeJs?v=0"></script>
    <script type="text/javascript" src="/bundles/modernizr?v=0"></script>
</asp:PlaceHolder>
<link href="/Content/mycss" rel="stylesheet" />

<link rel="stylesheet" href="//cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css" type="text/css" media="screen" />
<script src="//cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js" type="text/javascript">
<link href="/Content/appendgrid/jquery.appendGrid-1.6.1.min.css" rel="stylesheet" />

Code in body

<div class="form-group">
                    <div class="col-md-12">
                        <asp:Label runat="server" AssociatedControlID="tb1" CssClass="col-md-2 control-label">History <small class="error">*</small></asp:Label>
                        <div class="col-md-9">
                            <asp:TextBox runat="server" ID="tb1" CssClass="form-control autogrow" TextMode="MultiLine" />
                            <asp:RequiredFieldValidator runat="server" ControlToValidate="tb1" ErrorMessage="This field is required." CssClass="text-danger" SetFocusOnError="true" ValidationGroup="btnSave" />
                        </div>
                    </div>
                </div><table id="tbl"></table>

Code In Footer

$(document).ready(function () {
        $('#tbl').appendGrid({//options goes here
        });
    });

MORE INFO

On doing some more research, I find that the error is happening on my local development machine running Windows 10 & a staging website running on Microsoft Azure. However, the same code is running fine when published on a shared server. Is this because of some setting set in IIS of my local or Azure server?

I checked this link but could not find any suitable answer. Please advise what could be a possible solution to this.

Community
  • 1
  • 1
Nitesh
  • 2,286
  • 2
  • 43
  • 65
  • How does your code/ setup look like specifically? – empiric Sep 12 '16 at 20:53
  • Added parts of code – Nitesh Sep 12 '16 at 20:57
  • 1
    Worst case scenario, you could disable client-side validation for your validation control, and instead use something like jQuery Validate plugin, which is quite robust and customizable. – Alex Sep 12 '16 at 23:31
  • That's the worst case scenario. Will go for it if I do not get an alternative solution. There are about 100 controls on the page to validate :( – Nitesh Sep 13 '16 at 05:56

0 Answers0