Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning Visual C# 2005
This is the forum to discuss the Wrox book Beginning Visual C# 2005 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, Eric White; ISBN: 9780764578472
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 8th, 2006, 03:40 PM
Authorized User
 
Join Date: Oct 2005
Location: Summerville, SC, USA.
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBscript to C# .net Script

Ok,

I'm trying to recreate some code I know how to do in ASP vbscript in ASP.net C#.

Here is the code in vbscript.
Code:
<%
'Variables
Dim incfile, pg

'Define pg
pg = request.querystring("page")

'Logic for include
Select Case pg
  case "main"
     incfile = "main.asp"
  case "add"
     incfile = "add.asp"
  case "edit"
     incfile = "edit.asp"
End Select

%>
home can I recreate this is asp.net c#? Can anyone help with this?

  #2 (permalink)  
Old February 14th, 2007, 05:21 PM
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

Hi

To be honest I'm not sure if works with asp.net, but in C# the VBS bit should look like this:
Code:
string incfile = null;
string pg = Request.QueryString["page"];

switch(pg)
{
  case "main":
    incfile = "main.asp";
    break;
  case "add":
    incfile = "add.asp";
    break;
  case "edit":
    incfile = "edit.asp";
    break;
  default:
    // do something if none of the above?
    break;
}
The <%= incfile %> is the same.

Hope this helps
Phil
  #3 (permalink)  
Old February 14th, 2007, 05:35 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Did this ever work:



I thought that include files were included / combined first, before the combined page was parsed. So, when the file should be included, incfile doesn't have a value yet....

Anyway, are you familiar with User Controls in .NET? They more or less take the place of ASP includes, but offer a lot more. Additionally, when you included ASP files with mainly code, you could use the App_Code folder for shared methods.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.


Similar Threads
Thread Thread Starter Forum Replies Last Post
vbscript in asp.net 2.0 ufdylan ASP.NET 2.0 Basics 3 August 14th, 2007 12:02 PM
VBScript for Client-side controls in ASP.net cJeffreywang ASP.NET 1.0 and 1.1 Professional 1 March 22nd, 2007 08:02 PM
.NET component with script.aculo.us mega ASP.NET 1.x and 2.0 Application Design 0 May 22nd, 2006 11:46 AM
Putting VBScript in an ASP.NET page jturlington ASP.NET 1.0 and 1.1 Basics 1 May 14th, 2005 09:00 PM





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