Calling ASP.NET methods from JavaScript
This is really cool! OK, so you have a VB (or C#) method behind a web page. I had a Button_Click event. Clear, simple, easy.
The problem was, I needed to call that function BOTH, when the user clicked the button AND from JavaScript. Yuck.
I found I needed just TWO lines of code!
1) In the JavaScript, when you want to force the button to be pressed, call
__doPostBack('Control','')
2) In the VB.NET code, put this line immediately before the CLICK and COMMAND functions. I put this in front of both but did not test which one gets called...
<system.security.permissions.permissionsetattribute(system.security.permissions.securityaction.demand)> _
That was all it took. Like I said: "Cool"
Jenny

0 Comments:
Post a Comment
<< Home