?
Solved

Call ASP.NET sub from javascript

Posted on 2004-03-30
5
Medium Priority
?
601 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 1200 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 800 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

741 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