Link to home
Start Free TrialLog in
Avatar of anilkumarv
anilkumarv

asked on

Calling a server side function

I have a button, On the click event I want to call a server side vb proceedure

my client side code:
<input type=button onclick=<%abc()%>>

Server side code:
<SCRIPT LANGUAGE=vbscript>
  function abc()
      response.write "dfgsdgdf"      
  end function
</script>


can somebody tell me waht's the problem.


thanx in advance
Avatar of hcyu
hcyu

I think after the asp loaded from the server, all the server side tag and function will transform to be ordinary HTML code, and the page can't see any server side code. Therefore, you can't click a button to call a server side function.

What you can do is just clicking the button to call a client-side javascript function to do so. e.g.



<html>
<head>
<script language="javascript">
<!--
function showing(){
  window.alert("aaaaa");
}
//-->
</script>
</head>

<body>
<form>
<input type=button onclick="javascript:showing();">
</form>

</body>
</html>

I think you can call a vbs function, but it will only work in IE.
If all this code is together in the same script, hcyu is right. You can execute server side script while loading the page. Once you have loaded it you are on the client side. If you want to execute server side script after pressing a button you have to load a new asp page or reload the current page.

But is this what you want? If you just want a message to popup when you click the button you can use client side VBscript. Use something like:

<input type=button onclick=abc()>

<SCRIPT LANGUAGE = VBscript>
  Sub abc()
      msgbox "dfgsdgdf"
  End Sub
</SCRIPT>





Avatar of anilkumarv

ASKER

hcyu,
Thanx for your comment.But I want to write my functionality in server side whenever user clicks the button.
ASKER CERTIFIED SOLUTION
Avatar of JOK
JOK

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Won't be allow to call a server side without reloading the page or calling another page. If its server side, it means having to make another trip to the server.

What type of functionality are you trying to write?
Not quite true.

There is also a "remote scripting" capability in ASP which allows client side actions to generate server side effects (i.e., clicking a button on the client side causes the server to execute a routine and send new data to the client).

This seems to be what you want to do, and it has received some discussion on VI6talk@listbot.com in the past few days.

Unfortunately, I am not an expert on its use, so I only point you in that direction.

Tom
Yeah, haven't tried it before, so I keep forgetting about it. Try also going to www.asptoday.com and searching for "remote scripting" there's a couple of articles there.