p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Visual C# 2005 (http://p2p.wrox.com/forumdisplay.php?f=222)
-   -   VBscript to C# .net Script (http://p2p.wrox.com/showthread.php?t=51314)

tready December 8th, 2006 03:40 PM

VBscript to C# .net Script

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.

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?

philip_cole February 14th, 2007 05:21 PM


To be honest I'm not sure if works with asp.net, but in C# the VBS bit should look like this:

string incfile = null;
string pg = Request.QueryString["page"];

  case "main":
    incfile = "main.asp";
  case "add":
    incfile = "add.asp";
  case "edit":
    incfile = "edit.asp";
    // do something if none of the above?

The <%= incfile %> is the same.

Hope this helps

Imar February 14th, 2007 05:35 PM

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.


Imar Spaanjaars
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.

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

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