ASP.NET 网页的 title 有换行、空白字符的解决
2013-05-11 08:56
489 查看
在 ASP.NET 中,不论是通过 Page.Title 动态设置的,还是通过如下方式静态设置的:
生成的源代码都是这个样子:
可是我们需要的是这样的:
微软也不知道怎么搞的,非要把 title 生成那种格式。
原因
head 设置了 runat="server"
解决办法
只有取消 head 的 runat="server" 了。
但是
Page.Title 不能用了;
通过 HtmlHead 添加 charset、keywrods、description 不能用了;
继续解决
标签这样写 <title id="_title" runat="server"></title>,通过 _title.InnerText 动态设置,生成的标签类似 <title id="_title">博石网络</title>,但是客户还是不喜欢,不喜欢有个 id="_title"。
再继续解决:
然后设置 _title 的 Text 属性,也可以:
然后设置:_titleBox.Text = "<title>博石网络</title>";。两种方法都可以。
<head runat="server"> <title>博石网络</title> </head>
生成的源代码都是这个样子:
<head><title> 博石网络 </title></head>
可是我们需要的是这样的:
<head> <title>博石网络</title> </head>
微软也不知道怎么搞的,非要把 title 生成那种格式。
原因
head 设置了 runat="server"
解决办法
只有取消 head 的 runat="server" 了。
但是
Page.Title 不能用了;
通过 HtmlHead 添加 charset、keywrods、description 不能用了;
继续解决
标签这样写 <title id="_title" runat="server"></title>,通过 _title.InnerText 动态设置,生成的标签类似 <title id="_title">博石网络</title>,但是客户还是不喜欢,不喜欢有个 id="_title"。
再继续解决:
<head> <title><asp:Literal ID="_title" runat="server"></asp:Literal></title> </head>
然后设置 _title 的 Text 属性,也可以:
<head> <asp:Literal ID="_titleBox" runat="server"></asp:Literal> </head>
然后设置:_titleBox.Text = "<title>博石网络</title>";。两种方法都可以。
相关文章推荐
- 解决ASP.NET母版页title标签自动换行
- asp.net网页出现"名称以无效字符开头"的解决方法
- asp.net 网页 chart图标x轴标签显示不全的解决方法
- ASP.NET+AJAX解决网页打开等待问题
- asp.net网页防刷新重复提交、防后退解决办法集!
- asp.net 数据绑定 使用eval 时候报 字符文本中的字符太多 问题的解决方法
- 【ASP.NET】对不同产品的动态网页添加不同的title、keywords、description
- ASP.net中"名称以无效字符开头"问题解决?
- 【ASP.NET】"密码最短长度为7,其中必须包含以下非字母数字字符1"解决方法
- ASP.NET+AJAX解决网页打开等待问题
- ASP.NET B/S 网页刷新多次提交解决办法 一句话解决网页多次提交
- 【C#】对异步请求处理程序IHttpAsyncHandler的理解和分享一个易用性封装 【手记】走近科学之为什么明明实现了IEnumerable<T>的类型却不能调用LINQ扩展方法 【手记】手机网页弹出层后屏蔽底层的滑动响应 【手记】ASP.NET提示“未能创建类型”处理 【Web】一个非常简单的移动web消息框 【手记】解决EXCEL跑SQL遇“查询无法运行或数据库表无法打开...”
- ASP.net-asp网页不能访问-解决IIS的Server Application Error办法
- asp.net中如何动态改变网页的title
- Windows Server2003 sp2重装IIS后无法浏览asp.net网页解决方法
- asp.net 点击后退时,提示网页已过期,怎么样解决?
- ASP.NET Tricks&Tip:关于Tooltip(title)的换行问题
- ASP.net中"名称以无效字符开头"问题解决?
- ASP.NET中 “字符文本中字符太多”错误及解决方法
- ASP.NET+AJAX解决网页打开等待问题