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

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="btnQryFunctions" type="button" value="Query Functions"
language="javascript" 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="btnQryFunctions_onclick()" with
out the 'return'. What does the word 'return' do for me in this case?

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

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

For example, you might have some validation script within
'btnQryFunctions_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="btnQryFunctions" type="button" value="Query Functions"
language="javascript" 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="btnQryFunctions_onclick()" with
out the 'return'. What does the word 'return' do for me in this case?

Thanks.
--
mo*******@noemail.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="javascript" 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
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...
4
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...
15
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
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...
0
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,...

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.