Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# CSS href隐藏字段值和额外字符串的路径_C#_Asp.net - Fatal编程技术网

C# CSS href隐藏字段值和额外字符串的路径

C# CSS href隐藏字段值和额外字符串的路径,c#,asp.net,C#,Asp.net,所以我们有Extra/CSS/Template.CSSas href。但是我不知道如何让它工作。一种方法是直接修改页面上的href\u Load 首先,您为您的链接提供一个id href="<% hdfExtra.Value %>CSS/Template.css" 我们将在第页上呈现: csslink.Attributes["href"] = RootOfCss + "CSS/Template.css"; 如果用户更改了隐藏字段并在回发时使用它,那么隐藏字段就有了意义。如果您只是

所以我们有
Extra/CSS/Template.CSS
as href。但是我不知道如何让它工作。

一种方法是直接修改
页面上的href\u Load

首先,您为您的
链接提供一个
id

href="<% hdfExtra.Value %>CSS/Template.css"
我们将在第页上呈现:

csslink.Attributes["href"] = RootOfCss + "CSS/Template.css";
如果用户更改了隐藏字段并在回发时使用它,那么隐藏字段就有了意义。如果您只是从数据库中获取该值,那么就没有理由使用隐藏字段

用文字替换 您可以使用文字作为

csslink.Attributes["href"] = hdfExtra.Value + "CSS/Template.css";
由服务器渲染为

<link runat="server" id="csslink" href="<%=RootOfCss%>CSS/Template.css" rel="stylesheet" />
是否正确渲染为

<link href="<%=RootOfCss%>CSS/Template.css" rel="stylesheet" /> 

<link id="csslink" href="EXTRACSS/Template.css" rel="stylesheet" />
csslink.Attributes["href"] = hdfExtra.Value + "CSS/Template.css";
<asp:Literal runat="server" ID="cssliteral" EnableViewState="false"></asp:Literal>
cssliteral.Text = string.Format("<link id=\"csslink\" href=\"{0}/Template.css\" rel=\"stylesheet\" />", RootOfCss);
<head runat="server">
    <%=FullLink%>
</head>
public string FullLink = string.Empty;

protected void Page_Load(object sender, EventArgs e)
{
    RootOfCss = "EXTRA";

    FullLink = string.Format("<link id=\"csslink\" href=\"{0}/Template.css\" rel=\"stylesheet\" />", RootOfCss);
}
<link runat="server" id="csslink" href="<%=RootOfCss%>CSS/Template.css" rel="stylesheet" />
<link id="csslink" href="&lt;%=RootOfCss%>CSS/Template.css" rel="stylesheet" />
<link href="<%=RootOfCss%>CSS/Template.css" rel="stylesheet" /> 
<link href="EXTRACSS/Template.css" rel="stylesheet" />