Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-24-2007, 12:13 AM   PM User | #1
tylerh
New Coder

 
Join Date: Oct 2007
Posts: 46
Thanks: 7
Thanked 0 Times in 0 Posts
tylerh is an unknown quantity at this point
Converting a PHP file to ASP?

I was wondering if I could convert this php file to asp.. Here's the code
Code:
<?php
$id = $_GET['id'];
?>
  <?php
if ($id=="")
 {
?>
         <li><a href="layouts.php?id=1">Layout 1</a></li>
   <li><a href="layouts.php?id=2">Layout 2</a></li>
 
<?php
}
if ($id=="1")
  {
?>

   layout 1
       
     <?php
      }
      if ($id=="2")
      {
         ?>

   layout 2

       <?php
          }
            end
           ?>
Thanks!
tylerh is offline   Reply With Quote
Old 12-24-2007, 09:30 AM   PM User | #2
shyam
Senior Coder

 
shyam's Avatar
 
Join Date: Jul 2005
Posts: 1,563
Thanks: 2
Thanked 163 Times in 160 Posts
shyam will become famous soon enough
Quote:
Originally Posted by tylerh View Post
I was wondering if I could convert this php file to asp..
absolutely

query string variables are accessed using the Request.QueryString(varName) and the if-then construct is as follows

Code:
if t = "" then
end if
__________________
You never have to change anything you got up in the middle of the night to write. -- Saul Bellow
shyam is offline   Reply With Quote
Old 12-25-2007, 01:16 AM   PM User | #3
tylerh
New Coder

 
Join Date: Oct 2007
Posts: 46
Thanks: 7
Thanked 0 Times in 0 Posts
tylerh is an unknown quantity at this point
I tried this but i got an error
I'm a n00b at asp coding
haha

Code:
<%
Request.QueryString(id)
 if id = "" then
   response.write("<a href='test.asp?id=1'>1</a> ;;;; <a href='test.asp?id=2'>2</a>")
end if
  id id="1" then
 response.write("lol")
  end if
if id="2" then
  response.write("rofl")
end if
%>
:\
tylerh is offline   Reply With Quote
Old 01-03-2008, 05:28 AM   PM User | #4
reubenb
Regular Coder

 
Join Date: Sep 2002
Location: Adelaide, Australia
Posts: 472
Thanks: 3
Thanked 0 Times in 0 Posts
reubenb is an unknown quantity at this point
Try
Code:
<%
Dim t
t = Request.QueryString("id")
 if t = "" then
   response.write("<a href='test.asp?id=1'>1</a> ;;;; <a href='test.asp?id=2'>2</a>")
end if
  if t="1" then
 response.write("lol")
  end if
if t="2" then
  response.write("rofl")
end if
%>
reubenb is offline   Reply With Quote
Old 01-12-2008, 07:04 PM   PM User | #5
ghell
Senior Coder

 
Join Date: Apr 2003
Location: England
Posts: 1,192
Thanks: 5
Thanked 13 Times in 13 Posts
ghell is on a distinguished road
I'm not normally one for doing things for people rather than telling them how to do it, but as it is so simple:
Code:
<%
id = Request.QueryString("id")
Select Case id
  Case "1"
    Response.Write "Layout 1"

  Case "2"
    Response.Write "Layout 2"

  Case Else
    %>
    <li><a href="layouts.asp?id=1">Layout 1</a></li>
    <li><a href="layouts.asp?id=2">Layout 2</a></li>
    <%

End Select
This could have been done with
Code:
If ... Then
  ...
Else If ... Then
  ...
Else If ... Then
  ...
Else
  ...
End If
but Select Case makes this simpler.
__________________
My tech/code blog
ghell is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:27 PM.


Advertisement
Log in to turn off these ads.