By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,432 Members | 790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,432 IT Pros & Developers. It's quick & easy.

How to execute subroutines from button clicks?

P: n/a
I have read and tried every combination for hours. I'm sorry, but I
don't get it. How do I have a form with textboxes and buttons and
allow click events to execute a server function then display a
property on the client?

Here is code, albeit changed to show both paths I have tried to
follow, neither of which works. I also can't seem to find out how to
trap for the errors so I can see what's going wrong.

<%@ Language=VBScript %>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<%
Dim sNumber
sNumber = "102"

set etLine1 = Server.CreateObject("etTT40.etLine")
etLine1.Enabled = True
etLine1.DeviceName = "Analog Line 1(dxxxB1C1)"
etLine1.DeviceActive = True
response.write ("<br>etLine1.DeviceName: " & etLine1.DeviceName)
response.write ("<br>" & etLine1.DeviceActive)
'all above code works. I can even dial if I stick the dial
method here

Sub Dial()
etLine1.CallDial() ' Here is just get "error on page" at the
' bottom of my browswer
End Sub
%>

<SCRIPT LANGUAGE="VBScript">
<!-- This doesn't work, it just dials executes when the page loads
even when
I expect it to only get here with onclick
Sub Dial()
<%=etLine1.CallDial %>
end sub
-->
</SCRIPT>

</HEAD>
<BODY bgcolor="#B0E0E6">
End Sub

<FORM NAME="CallerID">
<p>Caller ID Number&nbsp;&nbsp;<input type="text"
name="TextCallerIDNumber" size="20" value="<%=sNumber%>">&nbsp;&nbsp;
<input type="button" name="btnDial" value="Dial This Number"
onclick="Dial()"></p>
<p>Caller ID Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
type="text" name="TextCallerIDName" size="20">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; </p>
<input type="button" name="btnHangup" value="Hangup Call"
onclick="Hangup()">

'I even tried to put <%=CallDial() here to no avail

</FORM>
</HTML>

This is obviously a telephony program and in this sample, I just want
to be able to dial a call by pressing a button. The server has the
hardware on it and would dial the call from there. I also would like
to be able do dial into the server and the OnCallerID event should
fire. I then want to display the caller ID on the client side.
Thanks.

Fred
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Navigate to your page and View->Source and you'll probably see this

<SCRIPT LANGUAGE="VBScript">
Sub Dial()

end sub
</SCRIPT>

So clicking your button does nothing. ASP executes first and the resulting
HTML is handed to the browser for display.

The basic answer is that you can't do what you're wanting using standard ASP
coding. There are technologies that let you run things on the server via
things in script but without knowing the ins and outs of what you want it is
hard to advise further.

What does this CallDial do?

"Fred" <fd************@aol.com> wrote in message
news:57*************************@posting.google.co m...
I have read and tried every combination for hours. I'm sorry, but I
don't get it. How do I have a form with textboxes and buttons and
allow click events to execute a server function then display a
property on the client?

Here is code, albeit changed to show both paths I have tried to
follow, neither of which works. I also can't seem to find out how to
trap for the errors so I can see what's going wrong.

<%@ Language=VBScript %>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<%
Dim sNumber
sNumber = "102"

set etLine1 = Server.CreateObject("etTT40.etLine")
etLine1.Enabled = True
etLine1.DeviceName = "Analog Line 1(dxxxB1C1)"
etLine1.DeviceActive = True
response.write ("<br>etLine1.DeviceName: " & etLine1.DeviceName)
response.write ("<br>" & etLine1.DeviceActive)
'all above code works. I can even dial if I stick the dial
method here

Sub Dial()
etLine1.CallDial() ' Here is just get "error on page" at the
' bottom of my browswer
End Sub
%>

<SCRIPT LANGUAGE="VBScript">
<!-- This doesn't work, it just dials executes when the page loads
even when
I expect it to only get here with onclick
Sub Dial()
<%=etLine1.CallDial %>
end sub
-->
</SCRIPT>

</HEAD>
<BODY bgcolor="#B0E0E6">
End Sub

<FORM NAME="CallerID">
<p>Caller ID Number&nbsp;&nbsp;<input type="text"
name="TextCallerIDNumber" size="20" value="<%=sNumber%>">&nbsp;&nbsp;
<input type="button" name="btnDial" value="Dial This Number"
onclick="Dial()"></p>
<p>Caller ID Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
type="text" name="TextCallerIDName" size="20">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; </p>
<input type="button" name="btnHangup" value="Hangup Call"
onclick="Hangup()">

'I even tried to put <%=CallDial() here to no avail

</FORM>
</HTML>

This is obviously a telephony program and in this sample, I just want
to be able to dial a call by pressing a button. The server has the
hardware on it and would dial the call from there. I also would like
to be able do dial into the server and the OnCallerID event should
fire. I then want to display the caller ID on the client side.
Thanks.

Fred

Jul 19 '05 #2

P: n/a
Fred wrote:
I have read and tried every combination for hours. I'm sorry, but I
don't get it. How do I have a form with textboxes and buttons and
allow click events to execute a server function then display a
property on the client?

Here is code, albeit changed to show both paths I have tried to
follow, neither of which works. I also can't seem to find out how to
trap for the errors so I can see what's going wrong.

<%@ Language=VBScript %>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<%
Dim sNumber
sNumber = "102"

set etLine1 = Server.CreateObject("etTT40.etLine")
etLine1.Enabled = True
etLine1.DeviceName = "Analog Line 1(dxxxB1C1)"
etLine1.DeviceActive = True
response.write ("<br>etLine1.DeviceName: " & etLine1.DeviceName)
response.write ("<br>" & etLine1.DeviceActive)
'all above code works. I can even dial if I stick the dial
method here

Sub Dial()
etLine1.CallDial() ' Here is just get "error on page" at the
' bottom of my browswer
End Sub
%>

<SCRIPT LANGUAGE="VBScript">
<!-- This doesn't work, it just dials executes when the page loads
even when
I expect it to only get here with onclick
Sub Dial()
<%=etLine1.CallDial %>
end sub
-->
</SCRIPT>

</HEAD>
<BODY bgcolor="#B0E0E6">
End Sub

<FORM NAME="CallerID">
<p>Caller ID Number&nbsp;&nbsp;<input type="text"
name="TextCallerIDNumber" size="20" value="<%=sNumber%>">&nbsp;&nbsp;
<input type="button" name="btnDial" value="Dial This Number"
onclick="Dial()"></p>
<p>Caller ID Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
type="text" name="TextCallerIDName" size="20">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; </p>
<input type="button" name="btnHangup" value="Hangup Call"
onclick="Hangup()">

'I even tried to put <%=CallDial() here to no avail

</FORM>
</HTML>

This is obviously a telephony program and in this sample, I just want
to be able to dial a call by pressing a button. The server has the
hardware on it and would dial the call from there. I also would like
to be able do dial into the server and the OnCallerID event should
fire. I then want to display the caller ID on the client side.
Thanks.

Fred


There are 5 ways that I know of to allow a user to cause server-side code to
execute by clicking a button:
1. Traditional form submission: the button submits the form to an asp page
containing the server-side code on the server, causing a page reload or a
new page to be displayed
2. Again: form submission, but using an IFrame in the target attribute of
the FORM tag, which will allow you to submit the form without unloading the
page.
3. Remote scripting - this has been deprecated, but many people still use
it. Do a Google search to find more information. Or look it up at
msdn.microsoft.com/library
4. If you do not need results returned from the server-side code, you could
use an IMG element, setting its src property to the url of the asp page
containing the server-side code
you wish to run
5. You can use the XMLHTTP (aka XMLHTTPRequest) object - again, you can find
info via Google or at msdn.microsoft.com/library

Do some research and decide which method you wish to use. Options 2-5 all
involve some client-side programming, making it off-topic in this newsgroup.
You should post any request for further information about these options
(after doing your own research
first, of course <grin> ) to the appropriate client-side coding newsgroups:
look for groups with "dhtml" in their names, or simply use the
..scripting.jscript newsgroup.

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #3

P: n/a
Thanks Bob and Adrian. I'll be doing a lot more research on all those
options. Adrian, I'll tell you what the program should do:

1. The user loads a web page with a form that has 2 text boxes, one
for callerID Name and the Other for CallerID number.

2. The user sees a button that says "dial"

3. I have a telephony device attached to my IIS server where the ASP
code is running. When the user telephones the extension attached to
that device, I want to use an event in an ActiveX on that machine
(etLine_OnCallerID) to display the CallerID information it has back on
the page the user is viewing. When they press the Dial button, it
will take the number out of the Caller ID number field, call them
right back on that number and play a wave file. This is a very simple
test program, ultimately it will do a lot more, but this will teach me
how to get information back and forth.

I realize also that there may be better ways to rethink the problem as
to where the information is and where it goes. For example, since all
the program stuff is really happening in ASP, maybe something "calls"
the ASP page and the ASP page pushes the CallerID info to the HTML
page. Then when the button is pressed on the HTML page, it somehow
refers back to that ASP page to execute the Dial subroutine or even
calls another ASP page.

The first part of the program works, if that is the proper place to do
it. It displays a web page on the client that runs code on the server
that selects and activates the device and displays that it is active.
If I put the etLine.CallDial line there it will even use the device
(even a voicemodem) attached to that server and dial the number. But
when I try to use the button on the form to tell the server to dial
the number, I can't figure out how to do it. Thanks.

Fred
Jul 19 '05 #4

P: n/a
Bob,

I wonder if option 1 would work. Which option would you learn more
about based on my description? I'm wondering if I try option 1 if I
could have the client page call the ASP page right away, since it
would have to run immediately and be waiting for their call. Then
when the call triggers the OnCallerID event, I send the callerID info
to the client page (and refresh if that is what I have to do). Then
the button un-grays to allow the number the ASP page already has (and
was displayed on the client page) to dial. I'm happy to spend the
weekend reading if you can just help with a little more direction. I
hope events are the same as in VB and VBScript. Thanks again.

Fred
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.