Frage

Using this code within an aspx file

<% if(storeid=1) { %>
<script src="//d3c3cq33003psk.cloudfront.net/opentag-1234-abcd.js" async defer></script>
<% } %>
<% else if(storeid=2) { %>
<script src="//d3c3cq33003psk.cloudfront.net/opentag-1234-efgh.js" async defer></script>
<% } %>
<% else if(storeid=3) { %>
<script src="//d3c3cq33003psk.cloudfront.net/opentag-1234-ijklmn.js" async defer></script>
<% } %>
<% else if(storeid=4) { %>
<script src="//d3c3cq33003psk.cloudfront.net/opentag-1234-opqrs.js" async defer></script>
<% } %>

Compiling this gives me this error

Compiler Error Message: CS1525: Invalid expression term '<'

Source Error:

Line 62:    
Line 63:    // Specific Code test 17.4.2014
Line 64: <% if(storeid=1) { %>
Line 65:    <script src="//d3c3cq33003psk.cloudfront.net/opentag-1234-abcd.js" async defer>   </script>
Line 66: <% } %>

All of the <% and %> look ok. Where is it falling down?

War es hilfreich?

Lösung

It's storeid == 1, not storeid=1.

Andere Tipps

Replace this line:

<% if(storeid=1) { %>

With:

<% if( storeid == 1 ) { %>

By the way, this is true for all of the rest equality checks in the other lines of code.

Your storeid='1' is wrong and the rest of your else statement. it should be ==.

storeid == 1 and not storeid=1.

<% if(storeid=1) { %>

should be

<% if(storeid==1) { %>
<script src="//d3c3cq33003psk.cloudfront.net/opentag-1234-abcd.js" async defer></script>
<% } %>
<% else if(storeid==2) { %>
<script src="//d3c3cq33003psk.cloudfront.net/opentag-1234-efgh.js" async defer></script>
<% } %>
<% else if(storeid==3) { %>
<script src="//d3c3cq33003psk.cloudfront.net/opentag-1234-ijklmn.js" async defer></script>
<% } %>
<% else if(storeid==4) { %>
<script src="//d3c3cq33003psk.cloudfront.net/opentag-1234-opqrs.js" async defer></script>
<% } %>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top