Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir/Mam

I want to give javascript validation to a content page of a master page from an external javascript file.

I have tried but it is unable to include the .js file. Please help me if there is any other way.








With regards

Ranjan Pati
Posted

There is a post here[^] which describes a solution for master pages and style sheets. JavaScript could be the same solution and using this would make the JS available to all content pages.

If you're wanting the JS just on the content page, make sure you put it inside the ContentPlaceholder container, right before your closing tag. You won't need to modify your Site.Master if you take this approach.

If you're still having trouble, make sure you try a good Shift+Refresh (F5)
on the page as you might just be seeing the cached copy.

Cheers.
 
Share this answer
 
XML
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <!-- adding external script file-->
<script language="javascript" type="text/javascript" src="JScript.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900