473,327 Members | 1,952 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,327 software developers and data experts.

Add and event to a asp:button

vavc1980
hello!

I have a form in a aspx file, in which I have a button (asp:button), I want to add/attach an event (onclick, or onsubmit) using javascript, I know I just can type the syntax right there, but I was requested to do it through javascript document.getelementbyid.

Is that possible? if so, how?

Thanks
Sep 16 '08 #1
4 1624
Plater
7,872 Expert 4TB
You can attach javascript event handlers to your button that way.
If you want to attach a server-side code event handler to your button, I think you need to do that in server side code.
Sep 16 '08 #2
I got it!!

I wasn't using the "function" word before the name of the function I wanted to attach to the onclick event..

getelementbyid("item").onclick = function(){function_name();};

thanks for the reply anyway.
Sep 16 '08 #3
Plater
7,872 Expert 4TB
Hmm, you should have been able to do this:
getelementbyid("item").onclick = function_name;

I think you leave out the (), but it might work WITH them in too.
Sep 16 '08 #4
Hmm, you should have been able to do this:
getelementbyid("item").onclick = function_name;

I think you leave out the (), but it might work WITH them in too.
I tried to do that before but it wasn't working out until I added the 'Function()' word like I posted before and then between the {} the name of my function.

Thanks for replying Plater.
Sep 23 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Frag | last post by:
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...
4
by: joe.osowski | last post by:
I've been staring at this a while, and I haven't had much luck with it. So I figure I'll try Usenet. No matter what I try, it seems the event.button property is always "0". Here is my test...
2
by: giant food | last post by:
Hi, I'm writing an asp app. I have a text box with a validator and a submit button. Here is code from my .aspx file.... <asp:TextBox ID="txName" TextMode="SingleLine" Runat="server" />...
4
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the...
7
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the...
4
by: hb | last post by:
Hi, When I add an asp:button (ex: id=btnLog) on home.aspx, I need to create btnLog_Click() event in home.aspx.cs, and also link this event and the button in OnInit() method by adding:...
1
by: RUIZCJ | last post by:
Hi, I'm at my wits end!!! I have the following code. The submit button works on my home computer but when I copy the dll and the ASPX file to my host provider, the button does NOT fire. TIA...
7
by: Lam | last post by:
I want to dynamic generate a asp:button in C# class, not in the HTML code so that it can call the methods in the c# class, I try to use "Response.Write("<asp:button...>") it didn't show the button...
0
by: enantiomer | last post by:
Having a problem with visual studio 2005 doing ASP.net. when in source mode (i.e. looking at the html directly), in the properties toolbar is an option called "DOCUMENT". It has some basic...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.