Calling VB.NET CodeBehind From a Javascript on ASP.NET webpage

J

johnc

Hey all, just wondering if the subject of this post is possible. I
have a javascript on my asp page that detects browser onunload, and it
will successfully popup a messsage box. When I try to call a sub in my
codebehind, the sub never fires, and I receive no errors.

I've also tried unsuccessfully to take advantage of the application_end
and session_end sub's in the global.asax, but neither would work
correclty.

In case it matters, the sub in my codebehind simply queries an sql
database, and emails the information to my sales dept.

Thanks!
 
D

Dragon

Hi,
Hey all, just wondering if the subject of this post is possible. I
have a javascript on my asp page that detects browser onunload, and it
will successfully popup a messsage box. When I try to call a sub in my
codebehind, the sub never fires, and I receive no errors.

You can't call a serverside sub in your client JS/VBS. Remember that at
the point client scripts execute, there's already no codebehind, and no
serverside code, so you just can't call them.

Maybe, you could open a pop-up window in unload event with some server
page, and execute your proc in it, but to my mind, it isn't a good idea.

Roman
 

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

Top