473,715 Members | 6,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very simple question on Javascript with ASP button

Hi guys,

I searched around without any clear answer. Tons of stuff, but nothing concrete.

I am trying to call this Javascript function:

function ButtonClicked()
{
alert("The button has been clicked.");
}

Calling it from an HTML button is no problem at all. But there is no way I can call that function from an ASP button. I tried from the HTML side or the aspx side.

I understood that an ASP button run only on the server. But I can't believe you can't make that simple call. I really hate to use HTML button when the design with ASP on a Web Form is so fast and easy.

Since I am a newbie, some code example will be appreciated.

Briefly, I have an ASP button that I want to call the Javascript function "ButtonClic ked"

Thanks

Frag

Jul 20 '05 #1
11 4651
Frag wrote:
Hi guys,

I searched around without any clear answer. Tons of stuff, but nothing
concrete.

I am trying to call this Javascript function:

function ButtonClicked()
{
alert("The button has been clicked.");
}

Calling it from an HTML button is no problem at all. But there is no way I
can call that function from an ASP button. I tried from the HTML side or
the aspx side.

I understood that an ASP button run only on the server. But I can't
believe you can't make that simple call. I really hate to use HTML button
when the design with ASP on a Web Form is so fast and easy.

Since I am a newbie, some code example will be appreciated.

Briefly, I have an ASP button that I want to call the Javascript function
"ButtonClic ked"

Thanks

Frag


Hi Frag,

I haven't got a clue what an ASP-button is, but if it is some HTML generated
by a tool, just look into the code it produces.
If you see <a href="">blabla</a> that is where you can try to add some
simple code in the anchor, like onClick="".

If the code is always generated dynamically, you should read in the specs
how to add extra things to it (if possible).

Regards,
Erwin Moller

Jul 20 '05 #2
In article <eC**********@f e09.usenetserve r.com>, fr**@frag.com
enlightened us with...

Calling it from an HTML button is no problem at all. But there is no way I can call that
function from an ASP button. I tried from the HTML side or the aspx side.


Sure you can.
Attach the script to it.

http://dotnetextreme.com/articles/validationAspNet.asp
http://www.code101.com/Code101/Displ...le.aspx?cid=33

Questions about dotnet best directed to
msnews:microsof t.public.dotnet .scripting.

Oh, and I don't use dotnet. I found the answer on Google in about a
minute. Google is your friend.

--
--
~kaeli~
If a book about failures doesn't sell, is it a success?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #3

Public Sub btnCallJavascri pt_Click(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnCallJavascri pt.Click

lblScript.Text = "<SCRIPT
language='Javas cript1.2'>popUp )
</SCRIPT>"

End Su

Unregistered
-----------------------------------------------------------------------
Posted via http://www.forum4designers.co
-----------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message36240.htm

Jul 20 '05 #4
Unregistered wrote:
Public Sub btnCallJavascri pt_Click(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnCallJavascri pt.Click

lblScript.Text = "<SCRIPT
language='Javas cript1.2'>popUp )
</SCRIPT>"
Why do people continue to use the outdated language attribute? And when
they do use it, they use a buggy version number without knowing the
possible implications of it?

<script language="javas cript1.2">
a = 30;
b = 40;
if (a = b){
alert('They are equal')
}
else{
alert('They are not equal')
}
</script>

Test the above in Netscape 4.xx, and then any other browser.

End Sub
Unregistered -
------------------------------------------------------------------------
Posted via http://www.forum4designers.com
------------------------------------------------------------------------
View this thread: http://www.forum4designers.com/message36240.html


You really should get a real newsreader and subscribe to
new:comp.lang.j avascript and stop using a site that portrays itself as a
"private forum" when it is anything but that.

Its more a joke than anything else.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #5
"Randy Webb" <hi************ @aol.com> wrote in message
news:Wq******** ************@co mcast.com...
<snip>
<script language="javas cript1.2">
a = 30;
b = 40;
if (a = b){
alert('They are equal')
}
else{
alert('They are not equal')
}
</script>
Test the above in Netscape 4.xx, and then any other browser.
It might be best not to do the comparison with IceBrowser as it uses the
Rhino javascript engine and the docs for Rhino say it will respect
language="javas cript1.2" and use the alternative type-converting rules
(though I have never tested that, not using the language attribute
myself anymore).

It is a bit unfair to use the text "They are equal" when the test you
are performing is an assignment (not comparison), though it adequately
illustrates the problem.

Here are a few comparisons illustrations of the differences:-

<html>
<head>
<title></title>
</head>
<body>
<script language="javas cript1.2">
if("40" == 40){
document.write( '(&quot;40&quot ; == 40) is true.<br>')
}else{
document.write( '(&quot;40&quot ; == 40) is false.<br>')
}
if(0 == false){
document.write( '(0 == false) is true.<br>')
}else{
document.write( '(0 == false) is false.<br>')
}
if("" == false){
document.write( '(&quot;&quot; == false) is true.<br>')
}else{
document.write( '(&quot;&quot; == false) is false.<br>')
}
</script>
</body>
</html>
Posted via http://www.forum4designers.com

<snip>You really should get a real newsreader and subscribe to
new:comp.lang. javascript and stop using a site that portrays
itself as a "private forum" when it is anything but that.
I think that they have abandoned the pretence that they are a private
forum, though they have done little to dray attention to the reality and
are maintaining a number of other deceptions related to that original
one.

But they have also stopped fully reporting comp.lang.javas cirpt. So,
with no guarantee that any response made to someone posting from
forum4designers .com will even be seen there, and knowing that any reply
made will be garbled by inappropriate presentation, it is questionable
whether it is worth anyone's effort to compose a worthwhile response to
posts originating on that site.
Its more a joke than anything else.


A bad joke.

Richard.
Jul 20 '05 #6
Richard Cornford wrote:
"Randy Webb" <hi************ @aol.com> wrote in message
news:Wq******** ************@co mcast.com...
<snip>
<script language="javas cript1.2">
a = 30;
b = 40;
if (a = b){
alert('They are equal')
}
else{
alert('They are not equal')
}
</script>
Test the above in Netscape 4.xx, and then any other browser.

It might be best not to do the comparison with IceBrowser as it uses the
Rhino javascript engine and the docs for Rhino say it will respect
language="javas cript1.2" and use the alternative type-converting rules
(though I have never tested that, not using the language attribute
myself anymore).


Just one more reason *not* to use the language attribute.

It is a bit unfair to use the text "They are equal" when the test you
are performing is an assignment (not comparison), though it adequately
illustrates the problem.
In Netscape 4.xx with language="javas cript1.2", it does a comparison,
not an assignment. Since they are not equal, it will alert that they are
not equal. In modern browsers then it alerts they are equal because it
can set the assignment, thus its true, so it alerts.

Perhaps:

<script language="javas cript1.2">
a = 30;
b = 40;
if (a = b){
alert('I honor it as an assignment')
}
else{
alert('I honor it as a comparison')
}
</script>
Might have been better alerts.

<--snip-->
Posted via http://www.forum4designers.com


<snip>
You really should get a real newsreader and subscribe to
new:comp.lang .javascript and stop using a site that portrays
itself as a "private forum" when it is anything but that.

I think that they have abandoned the pretence that they are a private
forum, though they have done little to dray attention to the reality and
are maintaining a number of other deceptions related to that original
one.


I am not so sure they have. They censor out the part of the posts that
we normally quote/complain about. Namely, the generated signature thats
get posted. When viewing the post on the site, you do not see that
section of the post. But they showed my signature line (and yours as well).

http://www.forum4designers.com/message36240.html

Is this very thread, and if you look at the post that I replied to,
there is no signature on it telling where it was posted from nor the
link to the thread.

But they have also stopped fully reporting comp.lang.javas cirpt. So,
with no guarantee that any response made to someone posting from
forum4designers .com will even be seen there, and knowing that any reply
made will be garbled by inappropriate presentation, it is questionable
whether it is worth anyone's effort to compose a worthwhile response to
posts originating on that site.


And miss out on all this fun? You are kidding me, right? <g>

Actually, they showed this entire thread (so far anyway). Will be
interesting to see if anything from my post after gets "lost" or not.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #7
"Randy Webb" <hi************ @aol.com> wrote in message
news:et******** ************@co mcast.com...
<snip>
In Netscape 4.xx with language="javas cript1.2", it does a comparison, <snip>

You are right it does. How on earth can it decide when it is supposed to
be doing comparison and when it is supposed to be doing assignment? I
use the result of assignment expressions in - if - statements all the
time. In practice it is not very important if the language attribute is
not used at all but given how often I see scripts with version 1.2
language attributes I am surprised we don't see more problems directly
resulting from them (or could that just be the result of limited
testing).

<snip>... . But they showed my signature line (and yours as well).


Do they? I don't recall posting with a signature during the period in
which they have been operating.

<snip>
... , it is questionable whether it is worth anyone's effort to
compose a worthwhile response to posts originating on that site.


And miss out on all this fun? You are kidding me, right? <g>

<snip>

I will copy and paste a pre-written standard response. No effort, no
waste if it is not reported, potentially as much fun.

Richard.
Jul 20 '05 #8
Richard Cornford wrote:
"Randy Webb" <hi************ @aol.com> wrote in message
news:et******** ************@co mcast.com...
<snip>
In Netscape 4.xx with language="javas cript1.2", it does a comparison,
<snip>

You are right it does. How on earth can it decide when it is supposed to
be doing comparison and when it is supposed to be doing assignment?


Its a bug in the if conditional in javascript1.2 specifically. So it
only shows itself when you do if(something=so methingElse) instead of
if(something==s omethingElse). I have never tested it in any other
conditionals (while and for loops).
I use the result of assignment expressions in - if - statements all the
time. In practice it is not very important if the language attribute is
not used at all but given how often I see scripts with version 1.2
language attributes I am surprised we don't see more problems directly
resulting from them (or could that just be the result of limited
testing).
If its inside an if statement, it will do a comparison. Otherwise, it
does as its supposed to do. As far as I know, if (a=b) will always
result in true in modern browsers (the exception would be if a was read
only).
<snip>
... . But they showed my signature line (and yours as well).

Do they? I don't recall posting with a signature during the period in
which they have been operating.


I am so used to seeing signatures at the bottom, that I mistook your
name for a signature. It shows mine, so its actively censoring what it
appends to the posts.
<snip>
... , it is questionable whether it is worth anyone's effort to
compose a worthwhile response to posts originating on that site.


And miss out on all this fun? You are kidding me, right? <g>


<snip>

I will copy and paste a pre-written standard response. No effort, no
waste if it is not reported, potentially as much fun.


Post it when you get it written. Maybe we could add a very unique word
so that people could filter it out (much like the FAQ gets filtered by
some), but based on content instead of subject lines. Or better, a
unique phrase "forum4webdesig ner's site ........."
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #9
"Randy Webb" <hi************ @aol.com> wrote in message
news:8P******** ************@co mcast.com...
<snip>
... . As far as I know, if (a=b) will always
result in true in modern browsers ...

<snip>

The evaluated result of an assignment expression is the value assigned:-

var obj;
if(obj = document.getEle mentById("someI D")){
... //only if - obj - is assigned non-null value
}

- so it can type-convert to both true and false.

Richard.
Jul 20 '05 #10

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

Similar topics

1
1570
by: Keiron Waites | last post by:
Ok to understand what I'm doing you'll have to load the HTML file attached (code also below): When you select an item on the left and select the ">>" button, some alerts will come up telling you what's happening. The first 2 alerts will tell you which items are being added to the array arrayFbox. arrayFbox is a multidimensional array. The values being added are the 2 items that you did not select from the left box. Next, you will get...
5
3107
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the user clicks on the "Choose" button of the input field (to select a file on the local disk), then radio button B is automatically
0
1891
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I have run into is that the emitted html at the end of the process is slightly different and doesn't work. Please don't be put off by all the source code. All the guts are in this first base class, and it doesn't do much. The rest is trivial...
6
2295
by: Marc | last post by:
How could I directly trigger a very simple on localhost and a known port listening server from my internet browser client? Local host means the little server would be running on the client machine, where my browser resides. Browser would be IE, O.S. Windows 2000 or XP, and it's for an intranet application. The goal of the little server on the localhost client side would be to trigger a scanner, with the TWAIN library. Also this server is...
27
4617
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res = $doc->loadHTMLFile("./aBasicSearchResult.html"); if ( $res == true ) { $zip = $doc->getElementById('zipRaw_id')->value; if ( 0 != $zip ) {
2
8372
by: Evan | last post by:
Hey, I posted this yesterday, but no one had any ideas? C'mon now, I know this isn't that hard, i'm just a little new to javascript, and I can't quite figure this out. I searched and searched to try and find the answer to this, but I had no luck anywhere. It's a little different situation than I found anywhere else. I would simply put javascript into the <a> tag, but like I said, It's delivered via PHP, and I don't have access to it. I...
29
1698
by: Knut Olsen-Solberg | last post by:
I try to change the text in a <p> using getElementById(). I wonder what properties exists, and which one to use here. (The following does not work.) Regards Knut ______________________ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <TITLE>JavaScript</TITLE>
24
6334
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to have on his site, a Javascript Calculator for working out the cost of what they want, for example: 1 widget and 2 widglets = £5.00
0
8821
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8718
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9340
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9103
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7973
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3175
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.