Reputation: 5104
I found that even I use ResolveUrl to indicates the path, it still does not work unless I add javascript in the page that user control is embeded in.
<script src="<%= ResolveUrl("~/JS/jquery.js") %>" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
alert("aaaaa");
});
</script>
Is there a way to add JS into user control directly?
Upvotes: 1
Views: 3945
Reputation: 52523
If you're talking about creating UserControl-specific javascript, I know exactly what you're talking about. There's no real easy way to do it (aside from just adding a script tag with your script and/or src), so here's what I do:
Also, naming your separate JS file the same thing as your User Control helps.
Upvotes: 1
Reputation: 360572
<input type="checkbox" onclick="alert('you clicked me!') />
is one tiny sample. Beyond that, we'd need details of what you mean by "control".
Upvotes: 0