Is it possible to move in and out of ASP in an If statement like in PHP? For instance in PHP you can do this: <? if($n = $x) { ?> <p>Content content content</p> <? } ?> PHP: Is this possible in ASP? I am getting an error when I do it this way in ASP. If not, what is a suitable way to print out HTML if a certain condition is met? Thanks!
yes you can do this your code would look like this: <% If (n = x) Then %> <p>Content content content</p> <% End If %> Code (markup):
Hey Alex, When I do this, I get an error page, and it states that it was expecting the "End" even when it is there, just like you have.
Here is what I ended up doing. (The <!--#embed --> tags pull content into the template) I was trying to avoid having any HTML inside of the ASP by using what we are talking about. <% dim question_1 dim question_2 question_1=Request.Form("question_1") question_2=Request.Form("question_2") If question_1="" Then Response.Write("<form method='post' action='?page=<!--#embed page[0] -->_<!--#embed page[1] -->_<!--#embed page[2] -->' name='activity'>") Response.Write("<p class='bold'><!--#embed args=form,page[0]/page[1].html,page[2]_weigh_direction,weigh_direction --></p>") Response.Write("<p><!--#embed args=form,page[0]/page[1].html,page[2]_weigh_questions,question_1 --><br />") Response.Write("<textarea name='question_1' cols='50' rows='6'></textarea></p>") Response.Write("<p><!--#embed args=form,page[0]/page[1].html,page[2]_weigh_questions,question_2 --><br />") Response.Write("<textarea name='question_2' cols='50' rows='6'></textarea></p>") Response.Write("<p><input type='submit' value='Submit' /></p>") Response.Write("</form>") Else Response.Write("<p><!--#embed args=form,page[0]/page[1].html,page[2]_weigh_questions,question_1 --></p>") Response.Write("You said, """ & question_1 & """<br />") Response.Write("<p><!--#embed args=form,page[0]/page[1].html,page[2]_weigh_answers,answer_1 --></p>") Response.Write("<p><!--#embed args=form,page[0]/page[1].html,page[2]_weigh_questions,question_2 --></p>") Response.Write("You said, """ & question_2 & """<br />") Response.Write("<p><!--#embed args=form,page[0]/page[1].html,page[2]_weigh_answers,answer_2 --></p>") End If %> PHP:
I've never seen it done like that before. Does that actually work - I'd be really interested to know.
Well it's being run through an assembler script, so yeah it does work. Although I'm not too sure exactly how it works, I wasn't the one who wrote the assembler.