如何使asp.net超链接停止对url进行编码?
我有一个带有 DisplayMode="HyperLink"
的 BulletedList
。
<asp:BulletedList runat="server" DisplayMode="HyperLink" ID="LevelsList"></asp:BulletedList>
我使用以下代码将项目添加到列表中: LevelsList.Items.Add(new ListItem(curSubPage.PageName, curSubPage.shortURL));
URL 链接包含希伯来语字符串,并且它们被编码:
asp.net 生成的标记类似于:
<a href="%d7%91%d7%a0%d7%99%d7%99%d7%aa_%d7%90%d7%a4%d7%9c%d7%99%d7%a7%d7%a6%d7%99%d7%95%d7%aa_%d7%90%d7%99%d7%a0%d7%98%d7%a8%d7%a0%d7%98%d7%99%d7%95%d7%aa">בניית אפליקציות אינטרנטיות</a>
而正确的标记应该是:
<a href="בניית_אפליקציות_אינטרנטיות">בניית אפליקציות אינטרנטיות</a>
如何修复它?
I have got a BulletedList
with DisplayMode="HyperLink"
.
<asp:BulletedList runat="server" DisplayMode="HyperLink" ID="LevelsList"></asp:BulletedList>
I add items to the list with this code:
LevelsList.Items.Add(new ListItem(curSubPage.PageName, curSubPage.shortURL));
The URL links contain Hebrew strings and they get encoded:
The markup the the asp.net generates is something like that:
<a href="%d7%91%d7%a0%d7%99%d7%99%d7%aa_%d7%90%d7%a4%d7%9c%d7%99%d7%a7%d7%a6%d7%99%d7%95%d7%aa_%d7%90%d7%99%d7%a0%d7%98%d7%a8%d7%a0%d7%98%d7%99%d7%95%d7%aa">בניית אפליקציות אינטרנטיות</a>
While the right markup should be:
<a href="בניית_אפליקציות_אינטרנטיות">בניית אפליקציות אינטרנטיות</a>
How do I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从快速调查来看,ASP.NET 似乎将其编码在其“低级”代码中,因此没有直接的解决方案。
您可以简单地使用自定义中继器编写自己的项目符号列表:
并将其绑定在后面的代码中:
请注意,从我所见,IE8 仍然不支持非英语 URL 地址 - 上面的链接在该浏览器中不可单击,而Chrome 允许您单击它,但也可以将 URL 编码为其他内容。
From quick investigation, looks like ASP.NET is encoding it in its "low level" code, so no direct solution.
You can simply write your own Bulleted List using custom Repeater:
And to bind it in code behind:
Note that from what I've seen, IE8 still does not support non english URL address - the above link is not clickable in that browser, while Chrome let you click it, but encode the URL to something else as well.