473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do you execute VB code that resides in a Text File...

CES
All,

I'm trying to figure out how I would execute code that would be shared over
a number of wwwroot folders.

Basically it would be the equivalent of an .inc file only instead of
residing below the wwwroot it would exist above (FYI - I want to do this so
when information changes on a page like my "Terms of Use" it will be
reflected throughout each site I maintain) as apposed to changing the file
for each domain.

I've tried using StreamReader but have run into a problem. the page loads
(with the .txt file Embedded in the page without any problem) but the VB
code in the file is not executed:

'This is the code that calls the appropriate file.

accountRoot = "\\server\root_Folder\"

Dim footer_file As New IO.FileStream(accountRoot & "_includes\file.txt",
IO.FileMode.Open, IO.FileAccess.Read)

Dim myReader As New IO.StreamReader(footer_file)

Dim footer_txt As String

footer_txt = myReader.ReadToEnd()

response.write(footer_txt) ' I've tried server.execute(footer_txt) but I'm
getting error messages even when the page is empty.

-XXXXXXXXXXXXXX-

'This is what is returned to the browser (note - That the <%
=DatePart("yyyy", Now) %> is returned but is invisible on the page.

..

<p class="footer_header">

Copyright <% =DatePart("yyyy", Now) %> - XYZ, Inc. - All rights reserved.

<br />

..

I've just switched from VBS to VB so I'm sure this is the wrong approach so
any advice or guidance would be appreciated.

CES
Nov 17 '05 #1
3 1758
Well, remember that ASP.NET pages are compiled pages and not scripts.

The best thing that I can think of you doing is to create a class with the
code that you want to share. Sign it with a strong name and place it into
the GAC. Any .NET assembly can access the code then.

"CES" <NO**@NOEMAIL.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
All,

I'm trying to figure out how I would execute code that would be shared over a number of wwwroot folders.

Basically it would be the equivalent of an .inc file only instead of
residing below the wwwroot it would exist above (FYI - I want to do this so when information changes on a page like my "Terms of Use" it will be
reflected throughout each site I maintain) as apposed to changing the file
for each domain.

I've tried using StreamReader but have run into a problem. the page loads
(with the .txt file Embedded in the page without any problem) but the VB
code in the file is not executed:

'This is the code that calls the appropriate file.

accountRoot = "\\server\root_Folder\"

Dim footer_file As New IO.FileStream(accountRoot & "_includes\file.txt",
IO.FileMode.Open, IO.FileAccess.Read)

Dim myReader As New IO.StreamReader(footer_file)

Dim footer_txt As String

footer_txt = myReader.ReadToEnd()

response.write(footer_txt) ' I've tried server.execute(footer_txt) but I'm
getting error messages even when the page is empty.

-XXXXXXXXXXXXXX-

'This is what is returned to the browser (note - That the <%
=DatePart("yyyy", Now) %> is returned but is invisible on the page.

.

<p class="footer_header">

Copyright <% =DatePart("yyyy", Now) %> - XYZ, Inc. - All rights reserved.
<br />

.

I've just switched from VBS to VB so I'm sure this is the wrong approach so any advice or guidance would be appreciated.

CES

Nov 17 '05 #2
CES
What I'm really looking for is the vb.net equivalent to eval() that is in
VBScript... but alas it's not their.
CES

"CES" <NO**@NOEMAIL.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
All,

I'm trying to figure out how I would execute code that would be shared over a number of wwwroot folders.

Basically it would be the equivalent of an .inc file only instead of
residing below the wwwroot it would exist above (FYI - I want to do this so when information changes on a page like my "Terms of Use" it will be
reflected throughout each site I maintain) as apposed to changing the file
for each domain.

I've tried using StreamReader but have run into a problem. the page loads
(with the .txt file Embedded in the page without any problem) but the VB
code in the file is not executed:

'This is the code that calls the appropriate file.

accountRoot = "\\server\root_Folder\"

Dim footer_file As New IO.FileStream(accountRoot & "_includes\file.txt",
IO.FileMode.Open, IO.FileAccess.Read)

Dim myReader As New IO.StreamReader(footer_file)

Dim footer_txt As String

footer_txt = myReader.ReadToEnd()

response.write(footer_txt) ' I've tried server.execute(footer_txt) but I'm
getting error messages even when the page is empty.

-XXXXXXXXXXXXXX-

'This is what is returned to the browser (note - That the <%
=DatePart("yyyy", Now) %> is returned but is invisible on the page.

.

<p class="footer_header">

Copyright <% =DatePart("yyyy", Now) %> - XYZ, Inc. - All rights reserved.
<br />

.

I've just switched from VBS to VB so I'm sure this is the wrong approach so any advice or guidance would be appreciated.

CES

Nov 17 '05 #3
have a look at the system.process namespace
"CES" <NO**@NOEMAIL.com> wrote in message
news:ec**************@TK2MSFTNGP11.phx.gbl...
What I'm really looking for is the vb.net equivalent to eval() that is in
VBScript... but alas it's not their.
CES

"CES" <NO**@NOEMAIL.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
All,

I'm trying to figure out how I would execute code that would be shared

over
a number of wwwroot folders.

Basically it would be the equivalent of an .inc file only instead of
residing below the wwwroot it would exist above (FYI - I want to do this

so
when information changes on a page like my "Terms of Use" it will be
reflected throughout each site I maintain) as apposed to changing the file for each domain.

I've tried using StreamReader but have run into a problem. the page loads (with the .txt file Embedded in the page without any problem) but the VB
code in the file is not executed:

'This is the code that calls the appropriate file.

accountRoot = "\\server\root_Folder\"

Dim footer_file As New IO.FileStream(accountRoot & "_includes\file.txt",
IO.FileMode.Open, IO.FileAccess.Read)

Dim myReader As New IO.StreamReader(footer_file)

Dim footer_txt As String

footer_txt = myReader.ReadToEnd()

response.write(footer_txt) ' I've tried server.execute(footer_txt) but I'm getting error messages even when the page is empty.

-XXXXXXXXXXXXXX-

'This is what is returned to the browser (note - That the <%
=DatePart("yyyy", Now) %> is returned but is invisible on the page.

.

<p class="footer_header">

Copyright <% =DatePart("yyyy", Now) %> - XYZ, Inc. - All rights

reserved.

<br />

.

I've just switched from VBS to VB so I'm sure this is the wrong approach

so
any advice or guidance would be appreciated.

CES


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CES | last post by:
All, I'm trying to figure out how I would execute code that would be shared over a number of wwwroot folders. Basically it would be the equivalent of an .inc file only instead of residing...
0
by: Eric Wood | last post by:
We have an application that is accessed using shared drives, client executes program from server. We have already coded the program to create and save the a bat file either locally on the users...
3
by: CES | last post by:
All, I'm trying to figure out how I would execute code that would be shared over a number of wwwroot folders. Basically it would be the equivalent of an .inc file only instead of
4
by: Chris | last post by:
I posted this in the C# language group, then thought it might be more appropriate in this group. I would not cross-post except I want the answer so badly. I built small C# Web and Web Service...
5
by: VB Programmer | last post by:
Here's the quick situation: 1. Using VS.NET I create 1 fully functioning aspx page, with code behind. (Simple webform: It has a few text boxes, 1 hyperlink, 2 and buttons.) 2. I uploaded it to...
1
by: Eric Wood | last post by:
We have an application that is accessed using shared drives, client executes program from server. We have already coded the program to create and save the a bat file either locally on the users...
0
by: oliver | last post by:
QUESTION: How to access an object embedded in a UserControl through Javascript file? Another way to ask this question: How to execute script from a UserControl, accessing other objects in that...
0
by: nano2k | last post by:
Hi I develop a client/server application using webservices. So, I have a client app and a webservice that responds to client app requests - nothin' new. In certain circumstances (namely, when...
9
by: Pachydermitis | last post by:
Hi, Is there any way to execute a function by using it's pointer? The reason I want to do this is: I have a control on a form that I have wrapped with a class. I want to be able to dynamically...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.