ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old May 5th, 2003, 10:58 AM
Datamike's Avatar
Datamike Datamike is offline
Web Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2001
Location: Finland
Posts: 719 Datamike User rank is Corporal (100 - 500 Reputation Level)Datamike User rank is Corporal (100 - 500 Reputation Level)Datamike User rank is Corporal (100 - 500 Reputation Level)Datamike User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 27 m 33 sec
Reputation Power: 9
Multiple lines with one command

Hi all

I gotta ask this, since I'm in a dispute with my ASP teacher. We are writing small ASP scripts, you know trying to learn it but the way we write ASP is pretty complicated for me. Here is a simple example of our scritps:
Code:
<%
Language = VBScript
Dim strEtunimi

Response.Expires = 0
If Request.ServerVariables("QUERY_STRING") <> "" Then
  strEtunimi = Request.QueryString("etunimi")
  response.write "Your name is <b>" & strEtunimi & "</b>"
%>
<% Else %>
<html>
<body>

Personal data:
<form name="formis" method="get" action="vastaus_v2.asp">
Etunimi:&nbsp;&nbsp; <input type="text" name="etunimi" value="">
<p>
<input type="submit" value="Lähetä">&nbsp;&nbsp;
<input type="reset" value="Tyhjennä">
</form>

</body>
</html>
<% End If %>


What bothers me is the multiple opening and closing ASP tags on the document. With PHP I've got used to the idea that I can put everything inside one set of PHP tags. In this example both the Else and the End If are enclosed in their own ASP tags and that freaks me out (I like details). I can only imagine how this looks if we would be writing a much more complex and bigger application.

What I'd like is to enclose all of this inside one set of ASP tags and have Response.Write print all the necessery HTML code. Is this possible?
__________________
-- Tomi Kaistila
-- Developer's Journal

The more you learn, the more you know.
The more you know, the more you forget.
The more you forget, the less you know.

Reply With Quote
  #2  
Old May 5th, 2003, 11:15 AM
imbrokn imbrokn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Location: NJ
Posts: 428 imbrokn User rank is Corporal (100 - 500 Reputation Level)imbrokn User rank is Corporal (100 - 500 Reputation Level)imbrokn User rank is Corporal (100 - 500 Reputation Level)imbrokn User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 34 m 8 sec
Reputation Power: 10
Send a message via AIM to imbrokn
Of course you can put your whole page in respnse.write tags if you wish. But believe it or not Interleaved code is faster than all response.write statements. (See this article: http://www.4guysfromrolla.com/webtech/021302-1.shtml) I think PHP lends itself a little bit better to limiting the code to one set of <? ?> tags. Since your strings can wrap multiple lines as long as you end it with a ; when you are done. And the ability to write variables without having to concatentate strings. stuff like that. Plus, echo is much easier to write then response.write. I had half a mind to write a sub in asp:

PHP Code:
 sub echo (str)
  
response.write str
end sub 

but i thought that would piss off anyone else that needed to modify my code in the future.

Reply With Quote
  #3  
Old May 5th, 2003, 11:16 AM
defjamninja defjamninja is offline
Overly white
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Fresno, CA
Posts: 83 defjamninja User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Sure you could have response.write print out all of your html, but I think that may be more difficult to read and trouble shoot HTML issues. But you could do something like this. The only issue is that when you have something in double quotes you need to either use 3 quotes (I think), or use single quotes. This is why I just try to avoid that issue and just just have multipul <% %> tags.

Code:
<%
Language = VBScript
Dim strEtunimi

Response.Expires = 0
If Request.ServerVariables("QUERY_STRING") <> "" Then
  strEtunimi = Request.QueryString("etunimi")
  response.write "Your name is <b>" & strEtunimi & "</b>"
Else
  response.write "<html>"
  response.write "<body>"

  response.write "Personal data:"
  response.write "<form name='formis' method='get' action='vastaus_v2.asp'>"
  response.write "Etunimi:   <input type="""text""" name="""etunimi""" value=""">"
  response.write "<p>"
...
  response.write "</body>"
  response.write "</html>"
End If
%>

Reply With Quote
  #4  
Old May 5th, 2003, 11:23 AM
imbrokn imbrokn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Location: NJ
Posts: 428 imbrokn User rank is Corporal (100 - 500 Reputation Level)imbrokn User rank is Corporal (100 - 500 Reputation Level)imbrokn User rank is Corporal (100 - 500 Reputation Level)imbrokn User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 34 m 8 sec
Reputation Power: 10
Send a message via AIM to imbrokn
when i do use long response.write statements then you can always use the underscore to continute lines:

PHP Code:
 response.write "<html>" _
                       
"<head>" 
                      
"<title>HI there</title>" 
                       
"</head>" 


of course that will show in html as

<html><head><title>HI there</title></head>

unless of course you do this.

PHP Code:
 response.write "<html>" vbcrlf _
                       
"<head>" vbcrlf 
                      
"<title>HI there</title>" vbcrlf 
                       
"</head>" 


I'll also do my sql statements like this for readablity:

PHP Code:
 sql "select * " _
        
"from table1 " 
        
"where ID=1" 

Reply With Quote
  #5  
Old May 5th, 2003, 11:41 AM
Datamike's Avatar
Datamike Datamike is offline
Web Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2001
Location: Finland
Posts: 719 Datamike User rank is Corporal (100 - 500 Reputation Level)Datamike User rank is Corporal (100 - 500 Reputation Level)Datamike User rank is Corporal (100 - 500 Reputation Level)Datamike User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 27 m 33 sec
Reputation Power: 9
Thank you for such speady replies. They were really helpful. Rewritten code of the example script would look something like this:
Code:
<%
Language = VBScript
Dim strEtunimi

Response.Expires = 0
If Request.ServerVariables("QUERY_STRING") <> "" Then
  strEtunimi = Request.QueryString("etunimi")
  response.write "Etunimesi on <b>" & strEtunimi & "</b>"
Else
  response.write "<html>" & _
"<body>" & vbcrlf & _
"Henkilötietojen syöttäminen:" & vbcrlf & _
"<form name='formis' method='get' action='vastaus_v2.asp'>" & vbcrlf & _
"Etunimi:&nbsp;&nbsp; <input type='text' name='etunimi' value=''>" & vbcrlf & _
"<p>" & vbcrlf & _
"<input type='submit' value='Lähetä'>&nbsp;&nbsp;" & vbcrlf & _
"<input type='reset' value='Tyhjennä'>" & vbcrlf & _
"</form>" & vbcrlf & _
"</body>" & vbcrlf & _
"</html>"
End If
%>

Much more compact in my opinion and more simple to write more complicated applications, though a little clumsy with all the quotes and underscores but I got what I wanted

Thanks again for the advices.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Multiple lines with one command


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway