頁面上數十個腳本和樣式文件怎麼去合並又少寫人工干預?
首先,使用查找替換把所有的<script>和<link>替換為<resource>然後在<resrouce>中加上runat="server":
母板頁:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="StaticResourceMerge.DemoWebApp.Site1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<resource src='http://images.xxx.com/js/script/apiCommon.js' type="text/javascript"
runat="server"></resource>
<resource language="javascript" type="text/javascript" src="http://images001.xxx.com/js/my/v3/1m/site_sms_messages.js"
charset="utf-8" runat="server"></resource>
<resource href='http://images.xxx.com/css/0709/ibuyandisell.css' type="text/css"
rel="stylesheet" runat="server" />
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
母板頁
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
用戶控件:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs"
Inherits="StaticResourceMerge.DemoWebApp.WebUserControl1" %>
<resource language="JavaScript" type="text/javascript" src="http://images.xxx.com//js/jquery.1.3.2.js" runat="server"></resource>
<resource language="JavaScript" type="text/javascript" src="http://images.xxx.com//js/scroll.js" runat="server"></resource>