473,320 Members | 2,202 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,320 software developers and data experts.

Calling client side Javascript from a server side button

C
Hi,

I have a server side asp.net button on a web page.

On clicking the button I want to call some Javascript.

Can I not simply do a onclick="MyJavascript();" or is it necessary that I add the onclick as an attribute in my codebehind?

Thanks,
C.
Nov 18 '05 #1
1 2308
well if you want to bind server side control with client side script.. and
if that object has a server side event as well... then your aspx should look
like this
<asp:Button id=Button1 onclick="javascript:clientsideclick();"
onServerClick="serverEventHandler">

the preferred way is to use
Page.RegisterClientScriptBlock to register any custom javascript functions

you can hardcode the onclick and onserverclick
but again the preferred way is to use
Button1.Attributes.Add("onClick", "clientSideClick();");
Button1.Attributes.Add("onServerClick", "serverEventHandler");

hope this helps.. btw.. if you dont have server event you dont need to add
onServerClient attribute

--

Regards,

HD
"C" <an*******@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com...
Hi,

I have a server side asp.net button on a web page.

On clicking the button I want to call some Javascript.

Can I not simply do a onclick="MyJavascript();" or is it necessary that I add the onclick as an attribute in my codebehind?
Thanks,
C.

Nov 18 '05 #2

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

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
1
by: Stephen | last post by:
Hey Everyone, I have a problem with a web application due to the use of both client-side and server side script on the on-click event of a button. The client side script runs first as expected...
1
by: Stephen | last post by:
Hey Everyone, I have a problem with a web application due to the use of both client-side and server side script on the on-click event of a button. The client side script runs first as expected...
1
by: Stephen | last post by:
Hey All, I have a problem with a web application due to the use of both client-side and server side script on the on-click event of a button. The client side script runs first as expected however...
2
by: Matt | last post by:
I guess the principal differences between client-side and server-side code is that client-side code is processed in web browser, and server-side code is processed in web server. In ASP.NET web...
5
by: Mong | last post by:
Hi, I have a webform with various asp controls on it such as textboxes and dropdownlists. I'm fairly new to asp.net coming from VB6 and am wondering when it's best to use client side events and...
1
by: shri124 | last post by:
please tell me what is the difference between the client side and server side controls?
5
by: Ankur | last post by:
Hi Folks, I am new for this group. I want to clarify one thing what's a basic difference between Client Side Java Script and Server Side Java Script. how we can differentiate it. Why we called...
1
by: nudrat | last post by:
I have a form, where new text boxes are generated by onclick event of a button. The function required to generate text boxes is written in Java Script. but i have to count no of text boxes generated,...
3
by: sasimca007 | last post by:
Hello friends, I want to know what is the difference between 1.) client-side project and server-side project 2.) client-side programming and server-side...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: 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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
0
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.