MvcContrib网格小写排序查询字符串
当您使用开箱即用的 MvcContrib 网格排序时,它会自动将查询字符串 Column 和 Direction 附加到您的 URL。例如:
www.mysite.com/listing?Column=Bedrooms&Direction=Ascending
有没有办法将查询字符串(列和方向)小写,以便您得到:
www.mysite.com/listing?column=Bedrooms&direction=Ascending
我正在使用 ASP.NET MVC 3 和 MvcContrib 版本 3。
When you use MvcContrib grid sorting out-of-the-box, it automatically appends the querystrings Column and Direction to your URL. For instance:
www.mysite.com/listing?Column=Bedrooms&Direction=Ascending
Is there a way to lowercase the querystrings (Column and Direction) so that you get this:
www.mysite.com/listing?column=Bedrooms&direction=Ascending
I'm using ASP.NET MVC 3 with MvcContrib version 3.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,这些值被硬编码在
MvcContrib.UI.Grid.HtmlTableGridRenderer
类中:CreateRouteValuesForSortOptions
私有方法由RenderHeaderText
虚拟调用受保护的方法。因此,如果您想要小写参数名称,一种可能是编写自定义 GridRenderer另一种可能性是编写自定义路由以使 url 小写。您可以查看以下博客文章 说明了如何将应用程序中的所有 url 设为小写,但您可以根据需要进行调整。
Unfortunately those values are hardcoded in the
MvcContrib.UI.Grid.HtmlTableGridRenderer<T>
class:The
CreateRouteValuesForSortOptions
private method is invoked by theRenderHeaderText
virtual protected method. So if you want to have lowercase parameter names one possibility would be to write a customGridRenderer<T>
.Another possibility is to write a custom Route to make urls lowercase. You may take a look at the following blog post which illustrates how to make all urls in an application to be lowercase but you could tweak it to your needs.