将 jQuery 代码添加到 Index.aspx 页面
Adding jQuery code to Index.aspx pages
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<script runat="server">
void Page_Load(object sender, EventArgs e) {
Page.RegisterClientScriptBlock("MyScript",
"<script language=javascript>"+
"alert(Date());"+
"</script>");
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2><%: ViewBag.Message %></h2>
<p>
To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
</p>
</asp:Content>
这给了我以下错误:
Only Content controls are allowed directly in a content page that contains Content controls.
只需从旧索引页复制并粘贴到新索引页(或复制并粘贴脚本 src 引用(。 这与ASP完全无关。
包含jquery指向您页面的链接(在jquery使用代码之前(...
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
如果使用母版页,请将其添加到其中,以便所有页面都已包含它。然后,您所需要的只是按原样复制代码。
相关文章:
- Emberjs应用程序加载在除Index之外的所有路由上
- 分析高度属性时出现意外值{{specs.height}}.index.html
- 主干模板:index.jst.eco到index.jst.ejs
- 将 jQuery 代码添加到 Index.aspx 页面
- 如何在aspx页面之间传递参数
- AngularJS-需要在index.html页面中访问来自服务的数据
- 更改基于它的Select OPTION's INDEX(Jquery)
- 尝试创建一个具有z-index的堆叠菜单'使用HTML5/CSS3/JS
- .aspx页面上引导程序中的动态选项卡
- index.html使用webpack开发服务器未重新加载
- 从index.html调用函数,该函数无限循环
- 当我通过.aspx.cs创建按钮时,它不起作用
- RouteChangeStart事件在初始index.html页面加载时触发
- 在新的浏览器选项卡上加载新的aspx页面后调用JavaScript函数
- Is (!~index) faster than (index === -1)?
- aspx中鼠标悬停时横向扩展DIV
- KOValidation在错误消息中获取可观察值、$index()、$data等
- 为什么我可以'不要使用xx[this.index].style.display?它's说“;无法读取属性
- window.onload适用于aspx页面,但不适用于普通html
- 修改一个index.aspx文件,然后得到一个http 404