title: Call razor from javascript
body: <p>I have a radio button as follows:</p>
  
  <pre><code>&lt;input type="button" value="Select address" onclick="selectAddress(@item.Id)" /&gt;
  </code></pre>
  
  <p>Then, the following javascript:</p>
  
  <pre><code>            &lt;script&gt;
                  $(function () {
  
  
                      function selectAddress(selectedId) {
                          if ($('#TermsAccepted').is(':checked')) {
                              setLocation('@Url.RouteUrl("SelectCustomerAddress", new { addressId = selectedId})')
                          }
                          else {
                              $('#checkErrorMsg').toggle();
                          }  
                      }
                  })
              &lt;/script&gt;
  </code></pre>
  
  <p>The problem is that the code has a syntax error because selectedId is not know due to mixing razor and javascript. Is there a way to solve this problem?</p>