0

I am trying to convert the following Javascript code from C# razor in to use it in Vbhtml. When I plug the code in my vb.net environment, i get the following error " BC36637: The '?' character cannot be used here. " and the semi-colon ';' at the end of false gives me a syntax error as well. Thank you for guiding me on that.

<script type="text/javascript">
function AppViewModel() {
    var self = this;
    self.loggedIn = @(Request.IsAuthenticated ? "true" : "false");
}

    $(document).ready(function () {
        ko.applyBindings(new AppViewModel());
    });

</script>
Loic
  • 123
  • 1
  • 18
  • The `? :` is the C# Conditional (or Ternary) Operator, for the VB equivalent see http://stackoverflow.com/questions/576431/is-there-a-conditional-ternary-operator-in-vb-net – jmoerdyk Apr 21 '14 at 20:07
  • Thank you! but I am trying to find the best way to write that code in order to have the error removed. – Loic Apr 24 '14 at 11:51
  • @Loic: jmoerdyk just gave you the answer; `@(Request.IsAuthenticated ? "true" : "false")` becomes `@If(Request.IsAuthenticated,"true","false")`. though you could also just output `@Request.IsAuthenticated.ToString()` – Brad Christie Apr 24 '14 at 11:52
  • @jmoerdyk: Thank you! I was able to make work. Thanks again. – Loic Apr 24 '14 at 12:26
  • @BradChristie:Thank you! I was able to make work. Thanks again. – Loic Apr 24 '14 at 12:29

0 Answers0