| re: How to execute subroutines from button clicks?
Fred wrote:[color=blue]
> 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 <input type="text"
> name="TextCallerIDNumber" size="20" value="<%=sNumber%>">
> <input type="button" name="btnDial" value="Dial This Number"
> onclick="Dial()"></p>
> <p>Caller ID Name <input
> type="text" name="TextCallerIDName" size="20">
>   ; </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[/color]
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" |