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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CES

    #1

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

    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(a ccountRoot & "_includes\file .txt",
    IO.FileMode.Ope n, IO.FileAccess.R ead)

    Dim myReader As New IO.StreamReader (footer_file)

    Dim footer_txt As String

    footer_txt = myReader.ReadTo End()

    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("yy yy", Now) %> is returned but is invisible on the page.
    ....
    <p class="footer_h eader">

    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
    soany advice or guidance would be appreciated.
    CES


  • Rick Rothstein

    #2
    Re: How do you execute VB.net code that resides in a Text File...

    Almost everybody here is using VB6 or lower. While you may get a stray
    answer to VB.NET questions here, you should ask them in newsgroups devoted
    exclusively to .NET programming. Look for newsgroups with the word "dotnet"
    in their name.

    For the news.devx.com news server, try these

    vb.dotnet.discu ssion
    vb.dotnet.techn ical

    For the microsoft news server, try these newsgroups...

    microsoft.publi c.dotnet.genera l
    microsoft.publi c.dotnet.langua ges.vb

    There are some others, but these should get you started.

    Rick - MVP




    "CES" <None@noSpam.co m> wrote in message
    news:m46dnVr19b 4wqeaiRVn-vQ@speakeasy.ne t...[color=blue]
    > All,
    >
    > I'm trying to figure out how I would execute code that would be shared[/color]
    over[color=blue]
    > 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[/color]
    so[color=blue]
    > 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(a ccountRoot & "_includes\file .txt",
    > IO.FileMode.Ope n, IO.FileAccess.R ead)
    >
    > Dim myReader As New IO.StreamReader (footer_file)
    >
    > Dim footer_txt As String
    >
    > footer_txt = myReader.ReadTo End()
    >
    > 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("yy yy", Now) %> is returned but is invisible on the page.
    > ...
    > <p class="footer_h eader">
    >
    > Copyright <% =DatePart("yyyy ", Now) %> - XYZ, Inc. - All rights[/color]
    reserved.[color=blue]
    >
    > <br />
    >
    > ...
    >
    > I've just switched from VBS to VB so I'm sure this is the wrong approach
    > soany advice or guidance would be appreciated.
    > CES
    >
    >[/color]


    Comment

    Working...