You must Sign In to post a response.
  • Category: JavaScript

    .js file is not loading in master page

    hi all,

    I am using one common validation .js file for webapplication,when i call that .js file in masterpage it is not calling the js file when master page is binding
  • #757011

    Hi,
    You could do this using a ScriptManager
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    <scripts>
    <asp:ScriptReference Path="~/jquery.js" />
    </Scripts>
    </asp:ScriptManager>
    or,
    using the script tag in you r head html
    <script type="text/javascript"
    src="<%= Page.ResolveClientUrl("~/jquery.js") %>"></script>
    or,
    using a html.Raw helper class and writing a method to catch the absolute url.
    <script src="@Html.Raw(GetBaseStaticUrl() + "Scripts/jquery-2.1.3.min.js")" type="text/javascript"></script>
    public static string GetBaseStaticUrl()
    {

    string staticContentPath = System.Configuration.ConfigurationManager.AppSettings["staticcontentpath"];
    if (!string.IsNullOrEmpty(staticContentPath))
    {
    return staticContentPath;
    }
    else
    {
    return "~/staticcontent/";
    }

    }

    if all of the above doesn't work plaese send the code details.


    Thanks
    Tarun


  • Sign In to post your comments