473,569 Members | 2,611 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_co nnection""
value=""narrowb and"" onClick=""setNa rrowband()"">")

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

Jul 19 '05 #1
5 9055
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.g r> wrote in message
news:3f******@n ews.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_co nnection""
value=""narrowb and"" onClick=""setNa rrowband()"">")

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=vbscri pt>
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="javasc ript:setNarrowb and();" or
onClick="javasc ript:void(setNa rrowband());" (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.g r> wrote in message
news:3f******@n ews.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_co nnection""
value=""narrowb and"" onClick=""setNa rrowband()"">")

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_co nnection""
value=""narrowb and"" onClick=""setNa rrowband()"">")

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


<%@ Language=VBScri pt %>
<%
response.write( "<script type=""text/javascript"">" & vbCrLf & _
"function setNarrowband() {" & vbCrLf & _
" document.write( ""BROAD""); " & vbCrLf & _
" }" & vbCrLf & _
"</script>" & vbCrLf)
response.write( "<input type=""button"" name=""radio_co nnection""
value=""narrowb and"" onClick=""setNa rrowband()"" />")
%>

--
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******** ******@tk2msftn gp13.phx.gbl...

"Ãéþñãïò ÓôÜèçò" wrote:
The following code is supposed to display a message when pressing the
button?

<%
response.write( "<input type=""button"" name=""radio_co nnection""
value=""narrowb and"" onClick=""setNa rrowband()"">")

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


<%@ Language=VBScri pt %>
<%
response.write( "<script type=""text/javascript"">" & vbCrLf & _
"function setNarrowband() {" & vbCrLf & _
" document.write( ""BROAD""); " & vbCrLf & _
" }" & vbCrLf & _
"</script>" & vbCrLf)
response.write( "<input type=""button"" name=""radio_co nnection""
value=""narrowb and"" onClick=""setNa rrowband()"" />")
%>

--
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
2949
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 p3); The parameters here can be read either in the forward order from p1 till p3 or reverse order from p3 till p1. Can anyone explain what is the...
6
3299
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 in VBA from my other Access applications. This works fine and I'm quite happy with it... except for one area; error handling. In most of my...
14
2982
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() ' This method shows the form used to get the info If sWhereInt = "" Then DoCmd.OpenForm sFormNameInt, acNormal, , , acFormAdd, _
1
2889
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 written in C#. When the app calls my unmanaged functions, they work fine. But as soon as my unmanaged functions call managed functions (in the same...
5
3405
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 5), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to...
2
3139
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 the stack pointer and it does it by the command "add esp,8" after returning from the called function. My questions: 1. Is the stack pointer...
18
4329
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 can use dlopen/whatever to convert the function name into a pointer to that function, but actually calling it, with the right number of parameters,...
15
22813
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 could either be f1() or f2(). BRs!
11
3181
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 Esa_Init. When I make a call, VS2005 reports "AccessViolationException" and refers to the 4th parameter (EsaT_State_Handle). I don't know how to...
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 and my c++ code should call c code.but when i tried to call a function in c code externing that function in my c++ code, i am getting unresolved...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8125
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
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 we have to send another system

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.