http://
“网站图标”——就是在地址栏中或收藏夹中显示的图标。像什么雅虎中国就有。 在DNN中的实现方式: <asp:placeholder id="FAVICON" runat="server"></asp:placeholder>
后台代码向里面添加控件(这种方式还可以用来由后台向页面写JavaScript脚本,用来控制不允许页面复制,禁用右键等,这可以在主机设置信息中添加设置项,又是一个可改进的小地方) Private Sub ManageFavicon()Sub ManageFavicon()
' 从缓存中读取网站图标的地址 Dim strFavicon As String = CType(DataCache.GetCache("FAVICON" & PortalSettings.PortalId.ToString), String) If strFavicon = "" Then ' 如果网站图像的地址存在 If File.Exists(PortalSettings.HomeDirectoryMapPath & "favicon.ico") Then strFavicon = PortalSettings.HomeDirectory & "favicon.ico" If Not Common.Globals.PerformanceSetting = Common.Globals.PerformanceSettings.NoCaching Then ' 当设置需要缓存时将信息写入缓存 DataCache.SetCache("FAVICON" & PortalSettings.PortalId.ToString, strFavicon) End If End If End If ' 当网站图像的连接地址不等于空时,将它添加到页面中 If strFavicon <> "" Then ' 添加一个LINK标签HTML控件 Dim objLink As HtmlGenericControl = New HtmlGenericControl("LINK") ' 设置rel属性为SHORTCUT ICON objLink.Attributes("rel") = "SHORTCUT ICON" ' 设置图标路径 objLink.Attributes("href") = strFavicon ' 将LINK添加到FAVICON控件中 Dim ctlFavicon As Control = Me.FindControl("FAVICON") ctlFavicon.Controls.Add(objLink) End If End Sub
|
|