all groups > asp.net > january 2005 >
You're in the

asp.net

group:

Calling a function from a button...easy, right?!


Re: Calling a function from a button...easy, right?! Ryan Trudelle-Schwarz
1/31/2005 3:38:04 PM
asp.net:
[quoted text, click to view]

Do you want this to execute on the client or the server? Right now, your
script block is server code while your button's onclick handler is client
side.
Re: Calling a function from a button...easy, right?! Ryan Trudelle-Schwarz
1/31/2005 4:46:15 PM
[quoted text, click to view]

IIRC, the easiest method is going to be to add a Runat="server" to the button
tag, in which case the button should post back and call the method when clicked.
In case the input type="button" is not wired up to do that, you can use a
<asp:button in its place and get the same functionality (just change the
tag name and change value attribute to text and it should be good).
Calling a function from a button...easy, right?! ScooterMX
1/31/2005 11:30:46 PM
I just have a function that does some sql stuff. When I run this I get an
object expected error on the <input type="button"... line
Does anyone have a suggestion?
This is written for IE only - it's an internal tool...

Here is the code that fails.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>tool</title>

<%
Function flushActivity
Dim oConn, cSql
cSql= "UPDATE activity SET Content= '' WHERE Class_Number = 2"
set oConn = Server.CreateObject("ADODB.connection")
oConn.Open Session("DSN")
oConn.Execute(cSql)
Response.write("executing: " & cSql & "<br>")
oConn.Close
set oConn = nothing
End Function
%>

</head>
<body>

<form>
<input type="button" value="Flush Activity" onclick="flushActivity()">
</form>
</body>
</html>


Re: Calling a function from a button...easy, right?! ScooterMX
1/31/2005 11:52:25 PM

[quoted text, click to view]

Interesting... the function accesses a sql database, which is server side.
I assumed that the function was client side. whats the best way to go about
this, given that the db is on the server?

(thanks SO much in advance!)

AddThis Social Bookmark Button