1

Consider following:

 $("#myform").attr({ action:  "@Url.Action(MVC.Thing.Delete().AddRouteValue("id", myJsModel.Id )) });

I'm trying to set the action method of the form to a strongly typed T4MVC route. How do I insert a dynamic value from javascript into the route value?

I've seen the use of @: but I don't know how to insert it back into razor.

jaffa
  • 26,770
  • 50
  • 178
  • 289

1 Answers1

1

I don't think that using T4MVC here versus regular MVC syntax makes much difference when it comes to this issue.

When thing you might try is to generate a replaceable token on the server and do the replacement client side. e.g. something like

MVC.Thing.Delete().AddRouteValue("id", "SOMETOKEN")

And then take the generated path on the client and replace "SOMETOKEN" with myJsModel.Id.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Ok gotcha, I just thought there might be some special way of doing this. I might use String.format function to do this with {0}. Thanks. – jaffa Mar 21 '12 at 09:03