Solved

ASP inside JavaScript (runat=Server)

Posted on 2011-02-22
6
428 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
  • 4
  • 2
6 Comments
 
LVL 15

Expert Comment

by:pateljitu
Comment Utility
If you are using Javascript as code behind, try this syntax

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

Author Comment

by:Wayne Barron
Comment Utility
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 30

Author Comment

by:Wayne Barron
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 15

Assisted Solution

by:pateljitu
pateljitu earned 500 total points
Comment Utility
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 30

Accepted Solution

by:
Wayne Barron earned 0 total points
Comment Utility
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 30

Author Closing Comment

by:Wayne Barron
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now