I write in MVC.
I have UserControl that has inside only this
UPDATED
<div id="login-container">
<div id="login">
<script src="/Scripts/shared/Site.js" type="text/javascript"></script>
<input type="text" />
</div>
</div>
When I load this control through Ajax call(I return View("User开发者_C百科Control")), so the script isn't downloaded. The only way to fix it is to write
$.getScript("Scripts/shared/Site.js")
after
$("#container").html(UserControlHtml)
I realize that this happens only when I load UserControl through Ajax call, but I don't understand why. Can someone explain what is going on behind the scene? I want to understand why loading html with script inside it doesn't downloads the script
Thank you
I think you may find that your issue is inside the usercontrol. you should change the following line:
<script src="/Scripts/shared/Site.js" type="text/javascript"></script>
to:
<script src="<%=Url.Content('~/Scripts/shared/Site.js')%>" type="text/javascript"></script>
that's my guess anyway..
精彩评论