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

May 4th, 2004, 01:06 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ^_^;
|
|

May 4th, 2004, 07:16 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|

May 4th, 2004, 10:01 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ^_^;
|
|

May 4th, 2004, 10:13 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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?
|
|

May 4th, 2004, 10:29 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ^_^;
|
|

May 4th, 2004, 10:59 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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?
|
|

May 4th, 2004, 12:05 PM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ^_^;
|
|

May 4th, 2004, 12:41 PM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ^_^;
|
|

May 4th, 2004, 01:49 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
There may be easier methods, but you could execute the following statement:
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
|
|

May 4th, 2004, 10:13 PM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ^_^;
|
|
 |