asp.net 4.0中锚标记中的URL路由?
我正在使用列表视图,并在项目模板的列表视图中,我有带有 href 的锚标记。
<a class="linkbutton" href='<%# string.Format("Movie/Hindi-Movie/{0}/{1}",Eval("MovieId"),Eval("MovieName")) %>'><%#Eval("MovieName")%></a>
在全局文件中
我有
routes.MapPageRoute("HindiAboutMovie", "Movie/Hindi-Movie/{MovieId}/{MovieName}", "~/Bollywood/AboutMovie.aspx");
这个工作正常。 但在 MovieName 中,我在单词之间有空格,这使得 url 通过将“%”放置在空格中而变得丑陋。
就像
http://localhost:5703/Movie/Hindi-Movie/43/Kucch%20Luv%20Jaisaa
我试图制作
http://localhost:5703/Movie/Hindi-Movie/43/Kucch-Luv-Jaisaa
How to handle this html side in string.Format?
请指导我。
I am using listview and in listview in Item Template, i have anchor tag with href.
<a class="linkbutton" href='<%# string.Format("Movie/Hindi-Movie/{0}/{1}",Eval("MovieId"),Eval("MovieName")) %>'><%#Eval("MovieName")%></a>
and in Global file
i have
routes.MapPageRoute("HindiAboutMovie", "Movie/Hindi-Movie/{MovieId}/{MovieName}", "~/Bollywood/AboutMovie.aspx");
This works fine.
but in MovieName i have space between words which makes the url ugly by placing '%' in blank space.
like
http://localhost:5703/Movie/Hindi-Movie/43/Kucch%20Luv%20Jaisaa
where i am trying to make
http://localhost:5703/Movie/Hindi-Movie/43/Kucch-Luv-Jaisaa
How to handle this html side in string.Format?
Please guide me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过简单的调整,例如:
Have you tried a simple adjustment like:
我尝试过这种方法。
在 Html 中我写了
,在代码后面我写了一个方法。
这确实解决了我目前的问题。 :-)
I tried this approach.
In Html i wrote
and in code behind i wrote a method.
This did solve my issue at the moment. :-)