This is a migrated thread and some comments may be shown as answers.

Urls: Route constraints with ajax binding

0 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
JULIA
Top achievements
Rank 1
JULIA asked on 19 Apr 2011, 12:10 PM

Hello,

is there a way to use routeconstraints with ajaxbinding, without to obtain ugly urls.

For example:

c.Bound( m => m.MyId ).ClientTemplate( Html.ActionLink( "Ugly", "Action", new { id = "<#=MyId#>" }, new { @class = "t-button" } ).ToHtmlString() );

Produces: http://localhost:64795/Home/Action?id=1

 

c.Bound( m => m.MyId ).ClientTemplate( "<a href='" + Url.Action( "Action", "Home" ) + "/<#=MyId#>' class='t-button'>Nice</a>" );

Produces: http://localhost:64795/Home/Action/1

My route:

routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = string.Empty },
                new { id = @"^\d+$" }
            );

Is it correct that the only way is to use the second approach?

Regards,
Timo

Tags
Grid
Asked by
JULIA
Top achievements
Rank 1
Share this question
or