我使用一种 javascript,当我在没有母版页的页面中使用它时,它可以正常工作,但是当我在使用母版页的内容页面中使用它时,它不起作用我该怎么解决这个问题?
我没有在母版页中使用任何 JavaScript 代码,这是必要的吗?
//Page1 without MasterPage
....
<head runat="server">
<link rel="stylesheet" href="StyleSheet.css" type="text/css" media="screen"/>
<script src="jquery-1.4.4.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery.maskedinput.js" type="text/javascript"></script>
<script type="text/javascript">
$(function ()
{
$.mask.definitions['~'] = "[+-]";
$("#date").mask("99/99/9999"); //Date
$("input").blur(function ()
{
$("#info").html("Unmasked value: " + $(this).mask());
}).dblclick(function () {
$(this).unmask();
});
});
</script>
</head>
....
<body>
<form id="form1" runat="server">
date : <asp:TextBox ID="date" runat="server" ></asp:TextBox>
.....
//page2 with MasterPage
...
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link rel="stylesheet" href="StyleSheet.css" type="text/css" media="screen"/>
<script src="jquery.maskedinput.js" type="text/javascript" charset="utf-8"></script>
<script src="jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function ()
{
$.mask.definitions['~'] = "[+-]";
$("#date").mask("99/99/9999"); //Date
$("input").blur(function ()
{
$("#info").html("Unmasked value: " + $(this).mask());
}).dblclick(function () {
$(this).unmask();
});
});
</script>
</asp:Content>
....
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
date : <asp:TextBox ID="date" runat="server" ></asp:TextBox>
</asp:Content>
//Master Page
...
<head runat="server">
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>