473,666 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

button onclick event handler

I have an asp.net 2.0 application and put a html button on a web page. I
double clicked on the button and it crated the event handler for me and
created the stub js function for it like this:

<input id="btnQryFunct ions" type="button" value="Query Functions"
language="javas cript" onclick="return btnQryFunctions _onclick()" />

and the function it created was:

function btnQryFunctions _onclick() {

}

Question: why did it create this code? onclick="return
btnQryFunctions _onclick()"

Normally I would have just written: onclick="btnQry Functions_oncli ck()" with
out the 'return'. What does the word 'return' do for me in this case?

Thanks.
--
mo*******@noema il.noemail
Aug 25 '06 #1
2 2072
Hi,

In this case, it indicates that the function 'btnQryFunction s_onclick()'
will return a boolean value based on which the form will be submitted back.

For example, you might have some validation script within
'btnQryFunction s_onclick()' script function that. In case the validation
fails and you do not want the form to be submitted, you can return false
which will not let the form to be submitted.

Regards,
Augustin
http://augustinprasanna.blogspot.com

"moondaddy" wrote:
I have an asp.net 2.0 application and put a html button on a web page. I
double clicked on the button and it crated the event handler for me and
created the stub js function for it like this:

<input id="btnQryFunct ions" type="button" value="Query Functions"
language="javas cript" onclick="return btnQryFunctions _onclick()" />

and the function it created was:

function btnQryFunctions _onclick() {

}

Question: why did it create this code? onclick="return
btnQryFunctions _onclick()"

Normally I would have just written: onclick="btnQry Functions_oncli ck()" with
out the 'return'. What does the word 'return' do for me in this case?

Thanks.
--
mo*******@noema il.noemail
Aug 25 '06 #2
Hello Moondaddy,

I think difference here is the button you added is a html submit button
rather than ASP.NET server button. so the "" event handler you see here is
a client-side script rather than server-side event handler.

===========
<script language="javas cript" type="text/javascript">
// <!CDATA[

function Submit1_onclick () {

}

// ]]>
</script>
=============== =====

And in client-side script event hander, we can stop the event by return
false in event handler, that's why the auto-generated "onclick" attribute
is like below:

onclick="return function_hander ();"

If you add a ASP.NET server button and double click it, it will add an
server-side event handler in code-behind. and this code is executed at
server-side after postback and haven't return type.

Hope this help clarify this. If you have anything unclear, please feel free
to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

=============== =============== =============== =====

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 25 '06 #3

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

Similar topics

4
4782
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like Button.performclick? Thanks
4
340
by: yfng | last post by:
In a web form, I want the user clicks on one button and this button will trigger another button/link which will open a new browser window? How to do that? Is there any method like Button.performclick? Thanks
15
62044
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
17
9648
by: Eric | last post by:
I'm new to JavaScript and I wrote this code to play with. Oddly, if I enter text in a box and then press the button, I only get the onChange event for the text box and not the button's onclick event. But if I press the button without entering text first, the button click event does work. What's up? <html> <body> <h3>Events on Buttons and Text Boxes</h3>
0
8448
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...
1
8552
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
7387
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...
1
6198
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5666
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
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
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
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.