0

I have the following MVC Url Helper:

 var result = $(this).val();

 var url = '@Html.Raw(Url.WpActionUrl((object)@ViewBag.Org_ID, "DocumentList", "MP", (object)result,null, null))';

The problem that I am experiencing is that the code will not recognize"result" in the MVC Url Helper.

I tried to delimit the single quote but no luck.

 var url = '@Html.Raw(Url.WpActionUrl((object)@ViewBag.Org_ID, "DocumentList", "MP", (object) ' + result + ',null, null))';
8
  • You cannot use a value known only in JavaScript, client-side, in code that runs server-side. Commented Jan 30, 2020 at 19:48
  • @Amy I am trying to just update the url so it an accept it. This is all in the View so not sure why it would not be possible. Commented Jan 30, 2020 at 19:53
  • Your view is rendered server-side, before the client-side code has a chance to run. Commented Jan 30, 2020 at 19:56
  • Does this answer your question? How to pass a value to razor variable from javascript variable? Commented Jan 30, 2020 at 19:57
  • 1
    This is a duplicate of your previous question. Please refrain from duplicating your questions. You can edit it to provide more information, which will (probably) move it to the top of the home page. Commented Jan 30, 2020 at 20:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.