Reputation: 20078
whats wrong with the below code, its throwing me an error of Compiler Error Message: CS1002: ; expected
$(document).ready(function() {
$('<%=StartDate.UniqueID%>').datepicker({ showOn: 'button',
buttonImage: '../images/Calendar.png',
buttonImageOnly: true, onSelect:
function() { },
onClose: function() { $(this).focus(); }
});
});
<label for="sd">StartDate:</label>
<asp:TextBox ID="StartDate" runat="server"></asp:TextBox>
error
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
Upvotes: 1
Views: 6156
Reputation: 2158
This is caused when, on your page, you have a referenced the jquery library more than once.
For example:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" language="javascript" >
$(function() {
$('#datebox').datepicker();
});
</script>
</head>
<body>
<script type="text/javascript" src="js/jquery.js"></script>
<input type="text" id="datebox" />
</body>
</html>
Upvotes: -1
Reputation: 1
conflict .js reference (when more than one reference to jquery library within the same page). If you choose to keep more than one reference (but not the best choice, one reference would be better) the $.noConflict(); method could help in this case (see: enter link description here )
$.noConflict();
jQuery(document).ready(function ($) {
$(".dtp").datepicker();
});
Upvotes: 0
Reputation: 20078
the reason i was getting the error:
"Microsoft JScript runtime error: Object doesn't support this property or method"
because i was having conflict .js reference and there were two different set of .js on the page
hope this helps other.
Upvotes: 5
Reputation: 1349
Maybe this:
<div runat="server">
<script type="text/javascript">
$(document).ready(function () {
$('#<%=StartDate.ClientID%>').datepicker({ showOn: 'button',
buttonImage: '../images/Calendar.png',
buttonImageOnly: true, onSelect: function () { },
onClose: function () { $(this).focus(); }
});
});
</script>
</div>
Upvotes: 2