JQuery gives "Microsoft JScript runtime error: Object doesn't support this property or method" when run
I am using a JQuery plugin which is an input mask for a text box. The textbox and JQuery is part of a custom user control and is added dynamically to a repeater control, which is part of a wizard step and control.
However, when I reach the step where the repeater and the user control with JQuery is added, the JQuery throws the following error: "Microsoft JScript runtime error: Object doesn't support this property or method".
All my code is this:
<script src="../../Scripts/jquery.js" type="text/javascript"></script>
<script src="src="../../Scripts/jquery.maskedinput.js" type="text/javascript"></script>
<script lan开发者_JAVA技巧guage="javascript" type="text/javascript">
jQuery(function($){
$('#<%= date.ClientID %>').mask("99/99/9999");
});
</script>
<asp:textbox id="date" runat="server"/>
So, I am really stuck as to why I am getting this problem. Can anyone help me, because I do no know why I should be getting this error.
Thanks
It's that invalid <script>
tag, this:
<script src="src="../../Scripts/jquery.maskedinput.js" type="text/javascript"></script>
Should be:
<script src="../../Scripts/jquery.maskedinput.js" type="text/javascript"></script>
Since that tag's malformed, the plugin isn't being executed, so .mask()
isn't a method jQuery objects have in your page...once you fix the <script>
include it'll fix the issue.
If this is ASP.NET like it seems, I suspect the problem is your have your controls placed in a naming container. This adds a prefix to all controls and will change how you need to target the controls using jQuery.
Take a look in Developer Tools in IE or FireBug in Firefox and see if the IDs are what you think they are.
Example: A control named CommentsGridView might become: tcBanner_tbComments_commentsTabContent_CommentsGridView
This is taken from one of my projects.
Let me know if I'm anywhere close or if you need more detail.
精彩评论