ASP.NET Call Class Function

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
 
G

Guest

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)
 
B

Bonato Pierantonio

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
 
H

Hans Kesting

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
 
G

Guest

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)
 
Joined
Jul 6, 2009
Messages
1
Reaction score
0
Re:

Hi,
I am trying to do the same thing here , I am working on a swiping card reader, i want to get the string displayed in the textbox autumaticaly to be stored right into the database table without clicking on a buttom or pressing enter ,
i am reading the card in my .aspx file but the transaction with the database is been done in a method in my aspx.cs file ! how can I combine both... and i did try on_text_change , it didnt work I still need to press enter to get my string saved into the DB! any clues ?:-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,818
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top