Wrox Programmer Forums
|
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
 
Old August 29th, 2005, 09:24 AM
Banned
 
Join Date: Jul 2005
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
 
Old August 30th, 2005, 07:24 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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
 
Old August 31st, 2005, 09:10 AM
Banned
 
Join Date: Jul 2005
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





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





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