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
 
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?


philip_cole February 14th, 2007 05:21 PM

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

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.

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.


All times are GMT -4. The time now is 06:52 PM.

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