hukaka
asked on
where to define javascript functions in a page with master page?
hi experts
I saw some code samples put javascript functions in page header
but for a web page with master page ,there is no header in content page.
i tried put it in header of master page , seems not working
any advice?
thx
I saw some code samples put javascript functions in page header
but for a web page with master page ,there is no header in content page.
i tried put it in header of master page , seems not working
any advice?
thx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I've shown various ways and places to include/import JSCRIPT. Now you can see I've imported it and I've also put some inline too. Either way is fine but it is preferred to import it.
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Portal.master.cs" Inherits="Portal.Portal" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Home Page</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<!--[if IE 7]>
<link href="css/ie7.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 8]>
<link href="css/ie8.css" rel="stylesheet" type="text/css" />
<![endif]-->
<link href="css/global_styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="js/admin_nav.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/datePicker.js"></script>
<script type="text/JavaScript">
<!--
function popup() {
alert("Hello World")
}
//-->
</script>
<asp:ContentPlaceHolder ID="head" runat="server">
<!-- This is your child or content page header. You can put Javascript tags here too.-->
</asp:ContentPlaceHolder>
</head>
<body>
<div id="main_container">
<div id="contentWrapper">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<!--- This is the place holder for Master Content.
</asp:ContentPlaceHolder>
<!-- Closing Content Wrapper Div-->
</div>
<!--Closing Wrapper Div-->
</div>
</body>
</html>
Please do not split points to me. The other replies have answered your question fully. I'm just showing you a full page example. I do not deserve any points for this answer.
ASKER
in fact I have already tried the the same way rajkumar suggested before asking this question.
the function was not called.still trying:(
the function was not called.still trying:(
Open in new window