473,395 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

asp:net button and javascript

Hi,

Can anyone tell me how I convince my
<asp:Button id="Button1" onclick="stopClock()" style="Z-INDEX: 101; LEFT:
8px; POSITION: absolute; TOP: 136px" runat="server"
Text="Button"></asp:Button>
that will run javascript function - stopClock()

Regular html button does not seem to have a problem with that.

Anton, ml.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.583 / Virus Database: 369 - Release Date: 10.2.2004
Nov 18 '05 #1
3 1263
Dan
Change tag in your webform to:

<asp:Button id="Button1" style="Z-INDEX: 101; LEFT:
8px; POSITION: absolute; TOP: 136px" runat="server"
Text="Button"></asp:Button>

And then in your Page_Load, do:

Button1.Attributes.Add("onClick", stopClock()")
"Anton ml. Vahčič" <an**********@campus.fri.uni-lj.si> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
Hi,

Can anyone tell me how I convince my
<asp:Button id="Button1" onclick="stopClock()" style="Z-INDEX: 101; LEFT:
8px; POSITION: absolute; TOP: 136px" runat="server"
Text="Button"></asp:Button>
that will run javascript function - stopClock()

Regular html button does not seem to have a problem with that.

Anton, ml.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.583 / Virus Database: 369 - Release Date: 10.2.2004

Nov 18 '05 #2
Hi,

Smart. Thanks. Maybe one more question if you know perhaps. If my
JavaScript function stopClock() return some string (let's say "Today") and I
want that my Button1.Text is now changed to "Today". How do I do it?

Greetings,
Anton, ml.
----- Original Message -----
From: "Dan" <da*@dontspam.com>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Sent: Thursday, February 12, 2004 3:42 PM
Subject: Re: asp:net button and javascript

Change tag in your webform to:

<asp:Button id="Button1" style="Z-INDEX: 101; LEFT:
8px; POSITION: absolute; TOP: 136px" runat="server"
Text="Button"></asp:Button>

And then in your Page_Load, do:

Button1.Attributes.Add("onClick", stopClock()")
"Anton ml. Vahčič" <an**********@campus.fri.uni-lj.si> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
Hi,

Can anyone tell me how I convince my
<asp:Button id="Button1" onclick="stopClock()" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 136px" runat="server"
Text="Button"></asp:Button>
that will run javascript function - stopClock()

Regular html button does not seem to have a problem with that.

Anton, ml.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.583 / Virus Database: 369 - Release Date: 10.2.2004
Nov 18 '05 #3
You're trying to fire a client event from the server. This is what
you need to do:

1. Add this to Page_Load:

Button1.Attributes.Add ("onclick", "javascript:stopClock(); return
false;");

[Note that "return false" keeps the page from being posted; take that
out if you do want the page to be posted.]

2. Change the button declaration to this:

<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 8px; POSITION:
absolute; TOP: 136px" runat="server" Text="Button" />

[You might also want to set the CausesValidation property to false.]
Nov 18 '05 #4

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

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
7
by: IntraRELY | last post by:
I am using the following command to launch and .NET VB Executable, which is a simple Windows Form (printCheckClient.exe). I am using a HyperLink Control and works perfect....
2
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added...
11
by: Dot net work | last post by:
Hello. I've read many posts about disabling submit buttons, but I can't get these answers to solve my problem. I have a server side asp.net button, and under the button I have code behind...
4
by: Miguel Dias Moura | last post by:
Hello, I created a datalist in an ASP.Net / VB page. I display the image and price of a few products. When a user clicks an image I want to load the page "detail.aspx?number=id" and send the...
7
by: Tigger | last post by:
Dear Experts, I am working on ASP.NET. I have got a problem related to the usage of Javascript in ASP.NET. Please help. The story is the following: 1) I am developing an ASP.NET application. I...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
5
by: Stuart Shay | last post by:
Hello All I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a Number in a TextBox and go to the page selected. Since the OnClick Event does not work in ASP.NET 1.1 for a...
2
Frinavale
by: Frinavale | last post by:
JavaScript in ASP.NET Using JavaScript in ASP.NET pages can make your application seem to work faster and prevent unnecessary calls to the server. JavaScript can be used to perform client-side...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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
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
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...
0
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
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...

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.