Dean
Dean

Reputation: 159

using an IF type statement in c# .net aspx file

I'm much more of a SQL guy but wanted to know if there is an IF type equivalent in .NET?

Basically I want it so that if a person is on website 1 then they are assigned a bespoke jscript tag and if they move to site 2 the jscript tag changes to the one for that site

example

IF storeID=1 then jscript tag = <script src='//d3c3cq12345psk.cloudfront.net/opentag-22222-1000000.js'>
If StoreID02 then jscript tag = <script src='//d3c3cq99999psk.cloudfront.net/opentag-11111-1000000.js'>

But obviously not in a SQL type way.

Anybody give me a pointer?

Upvotes: 0

Views: 111

Answers (2)

Simon Whitehead
Simon Whitehead

Reputation: 65077

Yes.. you can do something like this..

<% if (storeID == 1) { %>
    <script src='//d3c3cq12345psk.cloudfront.net/opentag-22222-1000000.js'>
<% } %>

..etc.

Upvotes: 0

Patrick Hofman
Patrick Hofman

Reputation: 157098

You can write your if in embedded code blocks:

<% if(storeID=1) { %>
   <script src='//d3c3cq12345psk.cloudfront.net/opentag-22222-1000000.js'>
<% } %>
<% else if(storeID=2) { %>
   <script src='//d3c3cq99999psk.cloudfront.net/opentag-11111-1000000.js'>
<% } %>

Upvotes: 3

Related Questions