Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 29th, 2005, 09:24 AM
Banned
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default Newbie: Calling a VB doc from ASP.NET

My setup: XML > XSLT > CSS > ASP.NET/VB.NET (using transformNode) method
My entire site will be dynamic from one ASP.NET doc and several XML, XSLT, and CSS source docs using the QueryString, like this:
http://SERVER/DIRECTORY/index.aspx?p...ir1=&subdir2=&...

My question: How do you link a an external VB doc server-side within an ASP.NET page, and then call a function from that VB doc?

My problem: I've successfully been able to create this setup for my site which allows for me to load an external VB script that contains a function, and call that function from within the ASP.NET doc:
Code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" Debug="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="vb" runat="server" src="/newsite/bgscripts/vb/modules.vb" />
<%
...
Response.Write("<div id='screenright'>")
Response.Write(modules)
Response.Write("</div>")
...
%>
The doc "modules.vb" contains a function for a set of modules to be displayed:
Code:
Function modules

    If Not Page.IsPostBack Then

        Response.Write("Hello World!")

    End If

End Function
...and the result of the function is: Hello World!

I want to use this setup, only with a dynamic filename. This is what I thought might work:
Code:
<%
'Dynamic module(s)
Response.Write("<script language='vb' runat='server' src='/bgscripts/vb/modules_")
Response.Write(page_path + ".vb' />")
'Results in: <script language='vb' runat='server' src='/bgscripts/vb/modules_home.vb' />
%>
<%
Response.Write("<div id='screenright'>")
Response.Write(modules_home)
Response.Write("</div>")
%>
But this setup isn't working like the first. The error message says that "modules_home is not declared". I realize that it's likely a server-side vs. client-side issue, but I'm just not sure how to set this up for a dynamic site. So I hope that someone could help me to see the light. Thanks for any & all help.

KWilliams
Reply With Quote
  #2 (permalink)  
Old August 30th, 2005, 07:24 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The problem you are experiencing is definately a server-side/client-side issue. You can't "response.write" something that needs to be processed by the server.

This seems like an overly complicated way of doing this. Why not build a compiled application that includes all of your files of functions so you can call them wherever you need them?

-Peter
Reply With Quote
  #3 (permalink)  
Old August 31st, 2005, 09:10 AM
Banned
Points: 1,561, Level: 16
Points: 1,561, Level: 16 Points: 1,561, Level: 16 Points: 1,561, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I actually thought of another way to accomplish this task. I've included all of the "modules_" functions within one VB doc, since there aren't going to be too many of them, and then call the function dynamically from within the index.aspx page. This is what I have:

QUERYSTRING:
http://SERVER/DIRECTORY/index/aspx?p...&modules=true&...

VB.NET DOC:
Code:
'***HOME PAGE MODULES***
Function modules_home

    If Not Page.IsPostBack Then
        Response.Write("Home Page")
    End If

End Function

Function modules_formsdocs

    If Not Page.IsPostBack Then
        Response.Write("Forms #38; Documents")
    End If

End Function
ASP.NET DOC:
Code:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" Debug="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="vb" runat="server" src="/bgscripts/vb/modules.vb" />
<%
'Declare qs value
Dim modules As String = Request.QueryString("modules")

'Customized modules for specified pages
Response.Write("<div>")

If modules = "true" Then

If page_path = "home" Then
Response.Write(modules_home)

Else If page_path = "formsdocs" Then
Response.Write(modules_formsdocs)
End If

End If

Response.Write("</div>")
%>

OUTPUT:
Home
or...
Forms & Documents

...and it works great. If the querystring value "modules" is empty or false, it doesn't pull any of the functions. If it's set to true, then the specified function is called from the source vb doc, and those results are displayed.

I guess the only question I have relates to calling a VB.NET doc from within an ASP.NET page, and hopefully you can help me out with this question:

When a document is included in an ASP.NET doc like this:
<script language="vb" runat="server" src="/bgscripts/vb/modules.vb" />
1) Is the entire document then loaded to the page, or is only the called function from within the body of the doc called? Thanks for your reply.

KWilliams
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling one VB.NET script from another kwilliams VB.NET 2 September 11th, 2006 06:26 AM
Good book for VB.NET newbie Dhodie VB.NET 2002/2003 Basics 4 April 7th, 2006 04:32 AM
Parse XML doc using VB.NET into ASP.NET page kwilliams Classic ASP XML 17 November 11th, 2005 10:42 AM
newbie vb.net question dib VS.NET 2002/2003 4 February 5th, 2004 04:46 PM



All times are GMT -4. The time now is 10:47 PM.


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