<%@ 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.
答案 0 :(得分:0)
只需将旧索引页复制并粘贴到新索引页(或复制并粘贴脚本src参考)。这根本与ASP无关。
答案 1 :(得分:0)
包含jquery指向您网页的链接(之前您的jquery-using代码)...
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
如果您使用母版页,请在其中添加,因此所有页面都已包含该页面。然后,您只需按原样复制代码即可。