Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 8th, 2008, 04:28 PM
Authorized User
 
Join Date: Nov 2007
Location: Grimsby, North East Lincolnshire, United Kingdom.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chris1012
Default If statement problem

ok am a complete noob when it comes to programming but i enjoy learning about recently i picked up one of the wrox books and i was wondering if one of you guys could help me out with a basic if statement problem

heres what i've got so far
<%
Dim strgay
strgay = request.Form("alias")
Response.Write strgay
%>

what am trying to do here is basically return a value from a webpage that has input field within a form to this webpage currently coding but i want the string variable entered to be conditional i've try different if statements but nothing i was wondering if someone could give me an example of some code for example if someone entered the name chris it would use the response.write statement and say access denied

i'de appreciate any feedback thanks in advance

in opposite world i love programming
__________________
in opposite world i love programming
  #2 (permalink)  
Old September 8th, 2008, 09:11 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Code:
<%
Dim strgay
strgay = Trim( "" & request.Form("alias") )
If strgay = "" Then
    Response.Write( "No alias given...so just go away" )
Elseif LCase(strgay) = "chris" Then
    Response.Write( "We hate you, Chris.  Go slip on a banana." )
Else
    Response.Write( "We love you, " & strgay & ".  Welcome!" )
End If
%>
Now... This really looks suspiciously like you are coding ASP and NOT ASP.NET! Because you do
     Dim strgay
and
     Response.Write strgay
and with ASP.NET, using VB.NET, you would normally do
     Dim strgay AS String
and
     Response.Write( strgay ) ' the parens are *necessary*

So if you aren't REALLY coding ASP.NET, you are posting in the wrong forum. And if you ARE coding ASP.NET/VB.NET, then you should be sure to ALWAYS compile all your code with
     Option Strict On
  #3 (permalink)  
Old September 9th, 2008, 09:45 AM
Authorized User
 
Join Date: Nov 2007
Location: Grimsby, North East Lincolnshire, United Kingdom.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to chris1012
Default

right ok yeah i am working with asp my bad but still the forum said asp.net and asp but any whos not to worry al sort this out one last question though before hand i've got all my if statements working like a charm but i now want to embed an image into an ifstatement and write a statement out aswell for example heres what i've got so far

ElseIf LCase(strgay) = "nick brown" Then
Response.Write ("YOUR NO PETER LEAVY: " & strgay & "<IMG SRC="nick.jpg">")

i can't see whats wrong tbh but am guessing its to do with the object type i've used in asp any feedback would be much appreicated thanks
Chris

in opposite world i love programming
  #4 (permalink)  
Old September 9th, 2008, 05:52 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

No, this forum specifically says it is "ASP Net 3.5 Beginner".

It is the GROUP of forums labelled "ASP.NET and ASP", but there are two separate forums for old-style ASP.

Anyway...

Response.Write "YOU'RE NO PETER LEAVY: " & strgay & "<IMG SRC=""nick.jpg"">"

To put a " mark inside a quoted string in VBScript (or in VB.NET, though you don't care about that), you use a pair of quote marks, as shown there. (This is, not so incidentally, the same scheme for using apostrophes in SQL queries.)

Notice that with VBScript you should NOT use parentheses with Response.Write. They don't really hurt, except that they cause a minor performance hit (microsecond or two), with Response.Write, but there are other circumstances where they can have strange side effects. I wrote a loooonnnnggg article on this back in 2001, if you care. But you probably don't.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with if...or...then statement lightmaker Classic ASP Basics 7 June 9th, 2008 06:49 PM
Where statement problem lryckman Access VBA 4 June 29th, 2007 08:46 AM
problem with delete statement thas123 SQL Server 2000 6 March 23rd, 2006 01:13 PM
Problem with "where = " select statement shirley65 SQL Language 3 October 17th, 2005 04:07 PM
Problem with FOR Statement bleutiger Classic ASP Databases 3 February 23rd, 2005 11:22 PM



All times are GMT -4. The time now is 08:02 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.