I use a kind of javascript,when i use it in a page without master page it works properly but when i use it in content page that use master page it doesn’t work what should i do for this problem?
i don’t use any code in masterpage for javascript is it necesssary ?
//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>
In asp.net when a UserControl is placed in a container the unique IDs of its contained controls are recalculated to avoid problems with multiple controls of the same type. this is true even for pages inside master pages.
to retrieve the correct unique ID of the controls in your page you need to write something like this
the
<%= ... %>will be evaluated at runtime and replaced with the correct id (ClientID is a property of asp.net control which holds the unique id of the control to be rendered)