0

I am migrating from MVC2 to MVC4 and I have a problem when I use the Url.Action function whith params from jquery. The generated url is wrong. Im using C# with Framework 4.5.1 This is my code:

            var doc = jQuery('#grilla').jqGrid('getCell', row_id, 'Doc');
            var tipoDoc = jQuery('#grilla').jqGrid('getCell', row_id, 'TipoDoc');
            var idA = jQuery('#grilla').jqGrid('getCell', row_id, 'A');


            var subGrilla = jQuery("#" + subgrid_table_id).jqGrid({
                url: '<%= Url.Action("ObDCob", "ListCob",new { area = "Cob", xsDoc = "'+doc+'",xsTipoDoc = "'+tipoDoc+'",xiA = "'+idA+'"}) %>',

When the HTML is generated, the following is generated:

'/clearing/WebBP/Cob/ListCob/ObDCob/'%2bdoc%2b'/'%2btipoDoc%2b'/'%2bidA%2b''

Instead:

'/clearing/WebBP/Cob/ListCob/ObDCob/doc/tipoDoc/idA'

Any solution for this? Thanks

James2707
  • 122
  • 1
  • 2
  • 13

1 Answers1

2

In MVC 4 use @ instead of <%= for Url.Action()

 url: '@Url.Action("ObDCob", "ListCob",new { area = "Cob", xsDoc = "'+doc+'",xsTipoDoc = "'+tipoDoc+'",xiA = "'+idA+'"})' 
Abdul
  • 2,002
  • 7
  • 31
  • 65