473,508 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling an ASP function

Well I'm a newbie in ASP but still I can't understand the reason to get an
error message when I click on the button.
The following code is supposed to display a message when pressing the
button?

<%
response.write("<input type=""button"" name=""radio_connection""
value=""narrowband"" onClick=""setNarrowband()"">")

Function setNarrowband()
response.write("BROAD")
End Function
%>

Jul 19 '05 #1
5 9054
Nooooooo

The onclick event works in the client side.

So you should write client side code for that.
--
Roji. P. Thomas
SQL Server Programmer
--------------------------------------
"Γιώργος Στάθης" <ge****@sch.gr> wrote in message
news:3f******@news.sch.gr...
Well I'm a newbie in ASP but still I can't understand the reason to get an
error message when I click on the button.
The following code is supposed to display a message when pressing the
button?

<%
response.write("<input type=""button"" name=""radio_connection""
value=""narrowband"" onClick=""setNarrowband()"">")

Function setNarrowband()
response.write("BROAD")
End Function
%>

Jul 19 '05 #2
Absolutely not.

The ASP code is executed on the server and nothing, except the result,
remain inside the HTML code when the page is displayed in the browser. If
you look at the source code from the browser, you will see that the function
setNarrowband() is totally missing. You need to use <script></script> tags
inside the HTML, with Javascript or VBScript code.

Also, when the HTML is displayed, you cannot write to it with a write
statement. It's something more complicated than that. Search Google for
DHTML (Dynamic HTML).

Try something like this instead:

<% response.write ........ %>

<script language=vbscript>
function SetNarrowBand()
msgbox "BROAD"
end function
</script>

There are other aspects, like the fact that the function setNarrowband may
or may not return a value and, if it returns a value, that this value can be
true of false. Different events, like onSubmit, onMouseOver, onClick, etc.,
may have a different response in each of these cases.

It will also explains why you will see something like
onClick="javascript:setNarrowband();" or
onClick="javascript:void(setNarrowband());" (Use javascript even if the
underlying function is coded in VBScript).

ASP.NET, which is not the same thing as ASP, bear some similitude to what
you have tried to do.

S. L.
"Γιώργος Στάθης" <ge****@sch.gr> wrote in message
news:3f******@news.sch.gr...
Well I'm a newbie in ASP but still I can't understand the reason to get an
error message when I click on the button.
The following code is supposed to display a message when pressing the
button?

<%
response.write("<input type=""button"" name=""radio_connection""
value=""narrowband"" onClick=""setNarrowband()"">")

Function setNarrowband()
response.write("BROAD")
End Function
%>

Jul 19 '05 #3

"Γιώργος Στάθης" wrote:
The following code is supposed to display a message when pressing the
button?

<%
response.write("<input type=""button"" name=""radio_connection""
value=""narrowband"" onClick=""setNarrowband()"">")

Function setNarrowband()
response.write("BROAD")
End Function
%>


<%@ Language=VBScript %>
<%
response.write("<script type=""text/javascript"">" & vbCrLf & _
"function setNarrowband() {" & vbCrLf & _
" document.write(""BROAD"");" & vbCrLf & _
" }" & vbCrLf & _
"</script>" & vbCrLf)
response.write("<input type=""button"" name=""radio_connection""
value=""narrowband"" onClick=""setNarrowband()"" />")
%>

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.


Jul 19 '05 #4
Performing a document.write after the page has loaded (since a user can't
really click on a button until the page has been rendered) is going to to
unpredictable things on different browsers. Also, where on the page is this
going to go? At the end?

I think DHTML would be the right angle (but again, the original poster
should go to a client-side group for the technical details).

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Roland Hall" <nobody@nowhere> wrote in message
news:#U**************@tk2msftngp13.phx.gbl...

"Γιώργος Στάθης" wrote:
The following code is supposed to display a message when pressing the
button?

<%
response.write("<input type=""button"" name=""radio_connection""
value=""narrowband"" onClick=""setNarrowband()"">")

Function setNarrowband()
response.write("BROAD")
End Function
%>


<%@ Language=VBScript %>
<%
response.write("<script type=""text/javascript"">" & vbCrLf & _
"function setNarrowband() {" & vbCrLf & _
" document.write(""BROAD"");" & vbCrLf & _
" }" & vbCrLf & _
"</script>" & vbCrLf)
response.write("<input type=""button"" name=""radio_connection""
value=""narrowband"" onClick=""setNarrowband()"" />")
%>

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.

Jul 19 '05 #5
"Aaron Bertrand - MVP" wrote:
Performing a document.write after the page has loaded (since a user can't
really click on a button until the page has been rendered) is going to to
unpredictable things on different browsers. Also, where on the page is this going to go? At the end?

I think DHTML would be the right angle (but again, the original poster
should go to a client-side group for the technical details).


I agree with all points you made. This example replaces the page with only
the text written. It is not a viable solution but it was an answer of how
to make, what he wanted, functional.

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2936
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
6
3295
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference...
14
2980
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() '...
1
2881
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
5
3396
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
2
3136
by: Geler | last post by:
A theoretical question: Sorry if its a beginner question. Here is a quote from the MSDN explaning the C/C++ calling convention.. It demonstrates that the calling function is responsible to clean...
18
4312
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
15
22792
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
11
3169
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for...
16
517
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.