Calling a code-behind function from vbscript function, possible?

Calling a code-behind function from vbscript function, possible?

Post by John Smi » Mon, 30 Dec 2002 20:13:14



I'm wondering if it's possible to call a function in the code-behind
file (ie. my_project.aspx.vb) from a vbscript function or subroutine
in the aspx file (ie. my_project.aspx.). One may suggest somehow
aggregate the vbscript function from aspx file to the code-behind file
and save all the trouble, but in my case this approach doesn't work
out very well. The main reason is I need to some do some complicated
validation that must be done in code-behind file with visual basic,
vbscript is not up to the job. Next, I'd also like to use msgbox to
show the result of validation, in this case however, aps.net forbids
the invocation of msgbox from code-behind code. So all in all, the
simplest work-around solution would be for a vbscript function to
invoke the validation function inside code-behind, which sends back to
result to the calling vbscript function. Then the vbscript function
displays proper message via msgbox depending on the return value.

Comments and/or pointers to on-line tutorials are much appreciated.

 
 
 

Calling a code-behind function from vbscript function, possible?

Post by Steve C. Orr, MCS » Tue, 31 Dec 2002 04:08:10


OK, just post back your page as normal, then put your validation code in the
change event as usual.
Then if you want to display a message box to the user when the page is sent
back to the browser you can use a line of code such as this to send the
appropriate client side code to pop up a message box.

RegisterClientScriptBlock("clientScript", "<script
language=JavaScript>alert('This is my message.');</script>")

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net


Quote:> I'm wondering if it's possible to call a function in the code-behind
> file (ie. my_project.aspx.vb) from a vbscript function or subroutine
> in the aspx file (ie. my_project.aspx.). One may suggest somehow
> aggregate the vbscript function from aspx file to the code-behind file
> and save all the trouble, but in my case this approach doesn't work
> out very well. The main reason is I need to some do some complicated
> validation that must be done in code-behind file with visual basic,
> vbscript is not up to the job. Next, I'd also like to use msgbox to
> show the result of validation, in this case however, aps.net forbids
> the invocation of msgbox from code-behind code. So all in all, the
> simplest work-around solution would be for a vbscript function to
> invoke the validation function inside code-behind, which sends back to
> result to the calling vbscript function. Then the vbscript function
> displays proper message via msgbox depending on the return value.

> Comments and/or pointers to on-line tutorials are much appreciated.


 
 
 

1. How do I call an inline JavaScript function from within my VB code-behind module?

I am working on an ASP.NET  project using VB code-behind that includes
typical database tasks. When a user clicks on the button to delete a record,
I would like them to be prompted with a message box asking them to confirm
that they really want to proceed with the deletion.

I couldn't find a way in VB.NET to create a client-side message box, so I
turned to JavaScript. I don't know JavaScript very well, but with a little
research, I was able to create a function that uses the "confirm" function
to prompt the user. I placed the JavaScript function inline with the HTML
code on my .aspx page, and it worked. Unfortunately, I haven't figured out
how to call the JavaScript function from inside my VB code behind module.
Nor can I figure out how to read the result of the JavaScript function from
inside my VB code behind module.

So I guess I have three questions:

1. Is there a way in ASP.NET to present a client-side message box to the
user using VB code behind?
2. If not, how do I call a JavaScript function that is located inside the
HTML of my .aspx page, from within my VB code behind module?
3. How do I read the result of the JavaScript function that located inside
the HTML of my .aspx page, from within my VB code behind module?

Any insights would be greatly appreciated.

Thanks!

Lou Valentine, MCSD
BORN Consultant

2. event ID 560

3. Calling Code-Behind Function from ASPX

4. newbie question

5. Convertin a scipt function in .aspx to a function in the code behind file

6. xntpdc authentication

7. Calling a javascript function from code behind

8. access IN OUT from C

9. Calling Jquery function from ASP.Net Code behind.

10. calling code behind function from javascript

11. call a javascript function from code behind

12. can I use client script to call code behind function

13. Can I use Attributes.Add to add a code behind function call?