views:

19

answers:

1

How can I put javascript code inside if block.

@{
    #if DEBUG
    $("#User").val("JDoe");
    $("#Password").val("secrect");
    #endif
}

When I try above code I get this compiler error:

Compiler Error Message: CS1056: Unexpected character '$'

And if I change $ to jQuery:

Compiler Error Message: CS0103: The name 'jQuery' does not exist in the current context

In my opinion it's a bug in Razor parser. How can I workaround that?

+1  A: 
@{#if DEBUG}
    $("#User").val("JDoe");
    $("#Password").val("secrect");
@{#endif}
takepara
Thank you!!!!!!
Zote