Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 May 4th, 2004, 01:06 AM
Authorized User
 
Join Date: May 2004
Location: San Francisco, CA, USA.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to CSharp1314 Send a message via AIM to CSharp1314 Send a message via MSN to CSharp1314 Send a message via Yahoo to CSharp1314
Default HelpX_x; How do I include a variable file in aspx?

You know in php you can use require to include a config file where it store all the variable values and you can just modify that config file and other php page can change the value by calling the variable in that config file?

How can I do that in aspx page?
let's say I want to store the variable
string serverName = "YourServerName";
in a config file (example config.aspx) then call that variable in that config file from index.aspx

please reply, thanks ^_^;

http://www.csharpusa.com
Website look and work like Microsoft Windows ^_^;
__________________
http://www.csharpusa.com
Website look and work exactly like Microsoft Windows ^_^;
  #2 (permalink)  
Old May 4th, 2004, 07:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

ASP.NET uses a different configuration file, which is named web.config in ASP.NET and app.config in VB.NET. The format of this file would be below:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="ServerName" value="YourServerName"/>
  </appSettings>
</configuration>

To reference this in code, you do:

string ServerName = ConfigurationSettings.AppSettings("ServerName");

This will retrieve the value from the config file.

Brian
  #3 (permalink)  
Old May 4th, 2004, 10:01 AM
Authorized User
 
Join Date: May 2004
Location: San Francisco, CA, USA.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to CSharp1314 Send a message via AIM to CSharp1314 Send a message via MSN to CSharp1314 Send a message via Yahoo to CSharp1314
Default

string ServerName = ConfigurationSettings.AppSettings("ServerName");
doesn't work but
string ServerName = ConfigurationSettings.AppSettings["ServerName"];
works, I dunno why ^_^;
so I just change () to [] dunno why.

http://www.csharpusa.com
Website look and work like Microsoft Windows ^_^;
  #4 (permalink)  
Old May 4th, 2004, 10:13 AM
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

That's the way it works; C# uses the square brackets to index arrays where Visual Basic .NET uses the parentheses.

In both languages, you could use the Get method to retrieve the item, and skip the array indexer altogether:

C#
string ServerName = ConfigurationSettings.AppSettings.Get("ServerName" );

or

VB.NET
Dim ServerName As String = ConfigurationSettings.AppSettings.Get("ServerName" )

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Mexico by Incubus (Track 7 from the album: Morning View) What's This?
  #5 (permalink)  
Old May 4th, 2004, 10:29 AM
Authorized User
 
Join Date: May 2004
Location: San Francisco, CA, USA.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to CSharp1314 Send a message via AIM to CSharp1314 Send a message via MSN to CSharp1314 Send a message via Yahoo to CSharp1314
Default

oh... I see, I just use get method, I'm so n00b, so embarassed ^_^;;

I have another question too
in php you can use phpinfo() to find out the version and other infos of php installed on the server, is there a way you can do that for asp.net? like grab the version info of asp.net installed on the server machine so it will display the version on the page.

thanks

http://www.csharpusa.com
Website look and work like Microsoft Windows ^_^;
  #6 (permalink)  
Old May 4th, 2004, 10:59 AM
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

Hi there,

AFAIK, there is not an easy page or method like the handy phpinfo() in PHP.

However, the Environment class exposes some interesting information about the, eeuhm, environment.

For example, it exposes a Version object that tells you something about the running Framework version, for example:

MyLabel.Text = Environment.Version.ToString();

Look at the Version class and the Environment class for more info.
Out of curiosity, why do you want to know which version of the Framework you're using?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Glass by Incubus (Track 5 from the album: S.C.I.E.N.C.E.) What's This?
  #7 (permalink)  
Old May 4th, 2004, 12:05 PM
Authorized User
 
Join Date: May 2004
Location: San Francisco, CA, USA.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to CSharp1314 Send a message via AIM to CSharp1314 Send a message via MSN to CSharp1314 Send a message via Yahoo to CSharp1314
Default

oh, because it would look cool at the bottom of the page, it's all about the coolness.
Powered by ASP.NET versioninfo
instead of me manually change the version number everything I upgrade the ASP.NET runtime, I just have the method automatically update it for me ^_^;;;
I'm a neat freak and perfectionist so... ^_^;

http://www.csharpusa.com
Website look and work exactly like Microsoft Windows ^_^;
  #8 (permalink)  
Old May 4th, 2004, 12:41 PM
Authorized User
 
Join Date: May 2004
Location: San Francisco, CA, USA.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to CSharp1314 Send a message via AIM to CSharp1314 Send a message via MSN to CSharp1314 Send a message via Yahoo to CSharp1314
Default

btw, how do I get a database server version info?
like MS SQL or MySQL version info?
I can't find the method to do this on MSDN Library.

http://www.csharpusa.com
Website look and work exactly like Microsoft Windows ^_^;
  #9 (permalink)  
Old May 4th, 2004, 01:49 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

There may be easier methods, but you could execute the following statement:
Code:
SELECT @@VERSION
This returns detailed information about the SQL Server you're executing the statement against. You may need to do some string parsing yourself to get nicely formatted results.
You can execute this statement with any of the methods you'd normally use, e.g. use the Execute method of a Connection object in "classic" ADO, or use ADO.NET objects.

Cheers,

Imar
  #10 (permalink)  
Old May 4th, 2004, 10:13 PM
Authorized User
 
Join Date: May 2004
Location: San Francisco, CA, USA.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to CSharp1314 Send a message via AIM to CSharp1314 Send a message via MSN to CSharp1314 Send a message via Yahoo to CSharp1314
Default

so I just execute that query eh? hmm... but I'm a n00b and I still haven't learned how to use ByteFX to make connection to a mysql server and execute queries with asp.net/C#, ByteFX is an open source data provider written in C# to connect to mysql with ado.net

I'm such a n00b ^_^;
I'm trying to make my own Control Panel/Website for Ragnarok Online Game Server, but the server is running on MySQL, I'm good with clientside website but I'm totally new to server-side stuff T_T

http://www.csharpusa.com
Website look and work exactly like Microsoft Windows ^_^;




Similar Threads
Thread Thread Starter Forum Replies Last Post
how to include .js file in .aspx page shanwaj ASP.NET 2.0 Basics 13 March 11th, 2008 07:36 AM
Dynamically include an aspx page ndkicha_1981 General .NET 0 October 19th, 2007 03:12 AM
Include Namespace in .aspx.vb?? mikedeepak Visual Studio 2005 6 June 1st, 2007 04:31 AM
difference between include file & include virtual crmpicco Classic ASP Basics 2 January 23rd, 2006 11:50 AM
Include file within aspx jieli1001 ASP.NET 1.0 and 1.1 Professional 2 July 29th, 2003 04:32 AM





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