这是我想做的一个例子:
内容方面(Structure.master):
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Structure.master.cs" Inherits="Structure" %>
<!DOCTYPE HTML>
<html>
<head runat="server">
<title>Bienvenue sur</title>
<meta charset="utf-8" content="" />
<link runat="server" href="App_Themes/Global/Metro.css?v=22" rel="stylesheet" type="text/css" />
<link runat="server" href="App_Themes/Global/Site.css?v=<%=Version %>" rel="stylesheet" type="text/css" />
<link runat="server" href="App_Themes/Global/Structure.css?v=22" rel="stylesheet" type="text/css" />
和代码隐藏(Structure.master.cs):
using System;
using System.Linq;
using BaseInstanceEntity = Library.Common.Entities.BaseEntities.BaseInstanceEntity;
using BaseInstanceManager = Library.Manager.BaseInstanceManager;
public partial class Structure : System.Web.UI.MasterPage
{
public string Version { get; set;}
protected void Page_Load(object sender, EventArgs e)
{
Version = System.Configuration.ConfigurationManager.AppSettings["Version"].Replace(".", "");
如图所示,我想将Version
var 显示到标题中,作为缓存控件。当我执行上面的代码时,该行的结果是:
<link href="../App_Themes/Global/Site.css?v=<%=Version %>" rel="stylesheet" type="text/css" />
就像代码没有被解释一样。我无法找到解释。为什么会这样?