ASP.NET Call Class Function

  • Thread starter Thread starter Bonato Pierantonio
  • Start date Start date
B

Bonato Pierantonio

Hi All,
It is possible inside a SCRIPT tag in the HTML page to call a SUB or
FUNCTION write in the codebehind ?
Example in the HTML
<SCRIPT Language=vbscript>
sub mySub
call mySecondSub
end sub
</SCRIPT>

mySecondSub reside in mypage.vb (codebehind)

Thanks
 
No, you're CLIENT SIDE VBScript cannot call a function that sits on the
SERVER...

What you COULD do is declare your function as Public and use it on the page
BUT it'll still run on the SERVER not the CLIENT.

HTH

(e-mail address removed)
 
To Run on Server side it is what I want but if I declare it as PUBLIC it
still give me an error "Object Required" !!!
What's wrong?
Thanks
 
Bonato said:
To Run on Server side it is what I want but if I declare it as PUBLIC
it still give me an error "Object Required" !!!
What's wrong?
Thanks

The browser sees just plain html and doesn't know anything about
asp.net. It has NO ACCESS AT ALL or knowlegde of any server
side code.
The reverse is also true: it is NOT possible for server side code
to execute client side code. One reason is that the client side does
not exist yet when the server side code executes.

Depending on what exactly you want to do, there are some tricks
to simulate such behaviour.

Hans Kesting
 
Well, your code example was not server side :)

The "Object Required" error is caused because the executing code cannot see
the function in scope. Which, with the code example you give, is because the
code is running in the client memory...

Without knowing WHEN you want the code to run it is difficult to advise you
further.

If you want the server-side mySecondSub to run as a result of a button click
then use a server-side button.

If you want to run it at some stage during page load (as the page is
output), why not call it in the Page_Load event?

Need to know what exactly you are trying to achieve...

(e-mail address removed)
 
Back
Top