I'd like to add a little variablility onto the path of my css link everytime my Site.Master view is processed. What is the correct way to do this? My code currently breaks on the Default.aspx saying I have not defined cssLink. Site.Master code below:
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
string cssLoc = "../../Content/css/expect.css?t=" + DateTime.Now.Ticks.ToString();
string cssLink = String.Format(@"<link rel=""stylesheet"" type=""text/css"" href=""{0}"" />", cssLoc);
}
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<asp:ContentPlaceHolder ID="head" runat="server">
<title></title>
</asp:ContentPlaceHolder>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<%= cssLink %>
<script type="text/javascript" src="../../Scripts/jquery.js"></script>
</head>
Also, is there anyway to fix the "XHTML transitional, Title occurs too few times" message?
UPDATE:
Please ignoring the scoping issue. See Richard's answer. I should note however that fixing this does not solve the issue.
I think because of the Inherits="System.Web.Mvc.ViewMasterPage" declaration the entire
<script runat="server">
block does not get processed.