Lets try this again

They have: 5,633 posts

Joined: Jan 1970

A few threads back I asked for some help and NO ONE RESPONDED!!! So let me try again. I need a way to make some ASP.NET functions global. One page is opend and it calls on another for some functions. I know Its going to be simple but I cant find it online or in any of my books.
Actually I'm going to go for 2 birds! Also I want to know If I can put Some HTML in a .html page that will open a ASP page but the page will not be visable.
Please help....

Busy's picture

He has: 6,151 posts

Joined: May 2001

I don't know ASP, but in PHP and in most languages you have to list globals in the functions, or if you are passing values to the function the value/variables may have to be set in the function and call

function ($a, $b)
{
do stuff
}

print function(1, 2);

part 2: don't get what you mean, why do you want to display invisible text in an ASP page? You know PHP don't ya? similar guidelines, failing that fall back to JavaScript

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I don't know ASP.NET either. How are your functions currently scoped? Are they in a class definition of some sort, or are they simply in another file? In the case of the former, you'll want to initialise your class and call one of its children; in the case of the latter, you'll want to include your other file, which presumably loads its contents into whatever namespace you're working in (global).

Let's see some code anyway.

I do not understand the second question at all.

dk01's picture

He has: 516 posts

Joined: Mar 2002

Write a webservice instead of trying to do global functions. Webservices can be used by a website or by an exe. They are basically like writing global logic that can be loaded or used all over your site/program (since .NET tries to make them almost the same thing). I wish I had my ASP.NET webservice examples but it was almost 2 years ago that I wrote them.

-dk

They have: 5,633 posts

Joined: Jan 1970

OK let me try to word it diffrently...
You go to a page that comtains this code...

<BODY>
<CENTER>
<H1><%= write_something(); %></H1>
</CENTER>
</BODY>
'But the "write_something()" function is in a diffrent file. For example....
function write_something() : String{
var return_this : String = "This will be written in the other page";
return return_this;}
'
Second part....
You open main.html and you done know it but it executes add_to_log.aspx.
How do I do that? I would perfer that you can have main.html on a diffrent server than add_to_log.aspx.
Can you help now?

They have: 5,633 posts

Joined: Jan 1970

webservice? tell me more.

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

use server side includes.

<!--#include virtual="/path_to_file/functions_file_name.ext"-->
'

I would suggest though as you haven't got to grips with how to use includes, don't attempt to write code for webservices.

Chris

Indifference will be the downfall of mankind, but who cares?
Venue Capacity Monitoring
Code Samples

They have: 5,633 posts

Joined: Jan 1970

For both cases? how is it server side? it looks html

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

It's an SSI directive Server Side Includes

for the second question, I'm not sure what you are asking for. But,
1/ you can't have .html files that include asp/asp.net code unless you change the application mappings on the server.
2/ You can't use includes to pull in code/data from a remote server with asp/asp.net.
3/ You can't execute code from html files (see 1)

Chris

Indifference will be the downfall of mankind, but who cares?
Venue Capacity Monitoring
Code Samples

They have: 5,633 posts

Joined: Jan 1970

So I cant just give someone this code. If they put it in their HTML it wont work. Sad
<!--#include virtual="http://www.host.com/log_this_site.aspx"-->'

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

correct, it won't work

They have: 5,633 posts

Joined: Jan 1970

So what would be the best idea to solve the second case? The best idea i have is a IFRAME. But then people whould be like what is this??

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

It depends on what you are actually trying to acheive by including the file. You can't execute functions from one site on another. All that can be included is the output from the script.

Chris

Indifference will be the downfall of mankind, but who cares?
Venue Capacity Monitoring
Code Samples

They have: 5,633 posts

Joined: Jan 1970

I dont want output from the file. The file will run compleatly on the server and will not send anything back to the html page.

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

just explain exactly what you are trying to do.
Bearing in mind that ASP code can only run on the server that it is located.

They have: 5,633 posts

Joined: Jan 1970

Ok, I'm working hard on a log for my site. I want to eather let people buy it or let them use it for free but the ASP will be on my server. So they just insert a line of code into their html page and it will regester a hit for their site on my server.

chrishirst's picture

He has: 379 posts

Joined: Apr 2005

right now it makes sense. That's not a major problem. Several ways it can be done depending of course on what kind of data you wish to store.
I have a script (in ASP, haven't got around to .net as yet) here ASP tracking Script. This is set as it stands to be called as a subroutine from a local page.
However it is a simple conversion to have it on a page and use a XMLHTTP call to "POST" data to it from ASP or PHP server-side or javascript client-side and pass some parameters including a UserID for the calling site.

extreme-dm do similar with javascript so you are not breaking new ground BTW, and if you want to see what data they collect you'll find someone's tracker here. There is also one here that I came across a few months ago at 2enetWorx.

Chris

Indifference will be the downfall of mankind, but who cares?
Venue Capacity Monitoring
Code Samples

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.