Solved

Call ASP.NET sub from javascript

Posted on 2004-03-30
5
599 Views
Last Modified: 2012-05-04
Is it possible to do this? If not, is there a workaround (i.e. a button just for that purpose and javascript calling button.click)?

Thanks
0
Comment
Question by:gromul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
ill earned 300 total points
ID: 10712301
not sure if this is,what you want, but...
this code in <body> section
--------------------

<span onclick='callASPSub("testme( 21, 666)")'>execute ASP<span>
<div id='aspdiv' />
<script type='text/javascript">
function callASPFile(func) {
        path="myAsp.asp?call="+func;
      var redir = document.createElement('script');
      redir.setAttribute('type','text/javascript');
        redir.src=path;
      var hlp=document.getElementById("aspdiv");
      hlp.appendChild(redir);
}
</script>
----------

in myAsp.asp include the file with  Sub testme( param1, param2)
and add this code.
-------------------
<%
stringToExec= request.querystring("call")
Execute stringToExec
%>
 ----------
0
 

Author Comment

by:gromul
ID: 10712505
Can you reload the complete page using javascript?
0
 
LVL 12

Expert Comment

by:ill
ID: 10712527
window.top.location.reload();
0
 
LVL 20

Assisted Solution

by:ihenry
ihenry earned 200 total points
ID: 10714914
I think it is possible to call a function or sub or even trigger an event from javascript code, but the page need to be posted back in order to execute the code behind. Just try the following link,

Execute a server-side function from javascript client-side code
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20716860.html

This is a bit tricky and you don't really have to follow the link provided, but once you got the idea you can actually make a slight changes to meet your own requirement.
0
 

Author Comment

by:gromul
ID: 10720412
Thanks guys.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question