如何使这个客户端代码服务器端代码?

时间:2022-06-22 03:21:05

I have wrote a client side code in server side code like this:

我在服务器端代码中写了一个客户端代码,如下所示:

 strHTMLGrid = strHTMLGrid + "<link rel='shortcut icon' href='/EVServer/Images/favicon.ico'/> \n";

This code looks like this in client side:

此代码在客户端看起来像这样:

<link rel="shortcut icon" href="/EVServer/Images/favicon.ico" />

On executing the HTML file dynamically it comes like this:

在动态执行HTML文件时,它是这样的:

<link rel='shortcut icon' href='/EVServer/Images/favicon.ico'/>

What to add in code behind so that i can get like this in my HTML file dynamically.Like this below in C#:

在代码中添加什么,以便我可以动态地在我的HTML文件中得到这样的内容。在C#中如下所示:

<link rel="shortcut icon" href="/EVServer/Images/favicon.ico" />

1 个解决方案

#1


0  

You can set the favicon from code behind.Just add a runat="server" attribute to the <link> element and you will be able to access it from code.

您可以从后面的代码设置favicon。只需将一个runat =“server”属性添加到 元素,您就可以从代码中访问它。

.ASPX:

<link id="favIcon" runat="server" rel="shortcut icon" />

Code behind:

protected void Page_Load(object sender, EventArgs e)
{
    favIcon.Attributes["href"] = "/EVServer/Images/favicon.ico";
}

#1


0  

You can set the favicon from code behind.Just add a runat="server" attribute to the <link> element and you will be able to access it from code.

您可以从后面的代码设置favicon。只需将一个runat =“server”属性添加到 元素,您就可以从代码中访问它。

.ASPX:

<link id="favIcon" runat="server" rel="shortcut icon" />

Code behind:

protected void Page_Load(object sender, EventArgs e)
{
    favIcon.Attributes["href"] = "/EVServer/Images/favicon.ico";
}