Can't use Response.Write in the <head> section of an aspx page?

I am trying to use the Response.Write () method to dynamically insert content into <head> on an aspx page. I need to enter a string value from a property of a code object that is a link to my CSS file. However, it is not handled properly at runtime. The object is public in the class and hydrated in the Page_Load () event. Inside the page page, I can successfully add other properties from the Corpoartion object without problems.

Why does this not work in <head>?

This is the part that is not distributed correctly:

<link href="<%= Corporation.PageStyleSheet %>" rel="stylesheet" type="text/css" />

Here is the whole <head>:

<head runat="server">
    <title></title>
    <link href="<%= Corporation.PageStyleSheet %>" rel="stylesheet" type="text/css" />
    <script language="JavaScript" type="text/JavaScript" src="cntv_menu.js"></script>
    <script language="JavaScript" type="text/JavaScript" src="cntv_category.js"></script>   
</head>

What is the reason that it will not expand correctly?

+5
3

<%= %> runat="server", <head>.

<%# %>, DataBind , link runat="server", id .

. , .

+6

:

this.myButton.Attributes.Add(attribute, value);

:)

0

, :

<%
Response.write("<link href=\"" + Corporation.PageStyleSheet + "\" rel=\"stylesheet\" />");
%>

P.S. , .

-1

All Articles