Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP inside JavaScript (runat=Server)

Posted on 2011-02-22
6
Medium Priority
?
445 Views
Last Modified: 2012-05-11
Hello All;

How do I get this to work?

<%if getType="Article" then%>
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">'+artHits+'</td></tr>';
<%elseif getAdmin="EditArticle" then%>
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">Hits Generated</td></tr>';
<%end if%>

Open in new window


If keeps giving me an error on the "Article"

Microsoft JScript compilation error '800a03ed'
Expected '('
/Test.asp, line 203
if getType="Article" then
----------------^

Thanks All;
Carrzkiss
0
Comment
Question by:Wayne Barron
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 15

Expert Comment

by:pateljitu
ID: 34957524
If you are using Javascript as code behind, try this syntax

<%if (getType=="Article") then%>
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 34957667
I am using VBScript, but have a JS code that is runat:Server
So, not really sure what would need to be used within it.

I have done the following
<%if (getType=="Article") then%>
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">'+artHits+'</td></tr>';
<%elseif (getAdmin=="EditArticle") then%>
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">Hits Generated</td></tr>';
<%end if%> 

Open in new window

And when run, I get an error on the <%

Microsoft JScript compilation error '800a03ea'
Syntax error
/Test.asp, line 204

0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 34957680
Removing the <% and %>
from the code, I get an error on the
else if

if (getType=="Article") then
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">'+artHits+'</td></tr>';
else if (getAdmin=="EditArticle") then
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">Hits Generated</td></tr>';
end if

Open in new window


Microsoft JScript compilation error '800a03ea'
Syntax error
/Test.asp, line 206

else if (getAdmin=="EditArticle") then
^

Also.
I would need to end the statement, but it does not seem like the

end if

is going to work, or does it?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 15

Assisted Solution

by:pateljitu
pateljitu earned 2000 total points
ID: 34961001
If the provided code is running as Jscript, try this syntax.

Not entirely sure on how code is integrated as "Case"  is outside of <%%>.
<%if (getType=="Article"){%>
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">'+artHits+'</td></tr>';
<%}else if (getAdmin=="EditArticle"){
case '[ct':return '<tr><th class="wikibox">Article Views</th><td class="wikibox">Hits Generated</td></tr>';
}

Open in new window

0
 
LVL 31

Accepted Solution

by:
Wayne Barron earned 0 total points
ID: 34963101
That still did not work, gave me an error on the first delimeter <%
I changed the way it works by this:


if getAdmin="EditArticle" then
artHits = "Page Hits"
end if

case '[ct':return '<tr><th class="wikibox">Article Views</th>
<td class="wikibox">'+artHits+'</td></tr>';

Open in new window


This way, if I am in the Admin section and editing the article, then it is going to display the words: Page Hits
And if I am viewing the live page, and the person has enabled the viewing of the page hits, then it will show the actual hits.

------
I am not a JS person so I am not really sure what to do with the code, so I am going to do it the way I am doing it now.

I am going to Award this post as Answer
And give you the points for you trying to help me.

Take Care and Thank you
Carrzkiss
0
 
LVL 31

Author Closing Comment

by:Wayne Barron
ID: 34995446
I took my code and did what I new how to do, I used my vbscript at the top of the page outside of the JS code, and then called the Variable inside of it code.

Works like expected, should have done this to begin with.
Thanks  pateljitu for you trying to help.

Carrzkiss
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question