在 asp.net 中打开 URL 时出错
我有以下 asp:HyperLink,它在 ColorBox 中打开:
<asp:HyperLink id="HyperLink2" runat="server" Text="Delete" class="example7" ToolTip="Delete this Album" NavigateUrl='<%# "delete_album_confirm.aspx?AlbumName=" & Eval("album_name") & "&PhotoFilename=" & Eval("photo_file_name") & "&AlbumID=" & Eval("album_id") %>'></asp:HyperLink>
如果 Eval("album_name")
没有空格,则上述内容可以正常工作。问题是当我有空格时,colorBox 无法打开。例如:
delete_album_confirm.aspx?AlbumName=testing album cover&PhotoFilename=resized_CIMG1426.jpg&AlbumID=41
谁能告诉我如何使用空格并且仍然可以正常工作?
任何帮助将不胜感激。
谢谢
I have the following asp:HyperLink which opens in ColorBox:
<asp:HyperLink id="HyperLink2" runat="server" Text="Delete" class="example7" ToolTip="Delete this Album" NavigateUrl='<%# "delete_album_confirm.aspx?AlbumName=" & Eval("album_name") & "&PhotoFilename=" & Eval("photo_file_name") & "&AlbumID=" & Eval("album_id") %>'></asp:HyperLink>
The above works fine if the Eval("album_name")
is without space. The problem is when i have spaces the colorBox doesn't open. For example:
delete_album_confirm.aspx?AlbumName=testing album cover&PhotoFilename=resized_CIMG1426.jpg&AlbumID=41
Can anyone tell me how I can use spaces and still get this working?
Any help would be much appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题可能是 URL 中不允许有空格,因此您需要使用 Url Encoding。你应该能够像这样完成:
The problem is probably that spaces are not allowed in URLs, so what you would need to is use Url Encoding. You should be able to accomplish that like this:
将空格替换为等效的 URL 编码
%20
。例如Replace your spaces with the URL encoded equivalent,
%20
. e.g.