473,795 Members | 3,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modify the builtin onclick event of button?

When add a button to a web form, if the button can CauseValidation , the
server emits client side javascript as:
<input type="submit" name="Button1" value="Button"
onclick="if (typeof(Page_Cl ientValidate) == 'function')
Page_ClientVali date(); "
language="javas cript" id="Button1" />

What I want to let the emitted javascript like :
<input type="submit" name="Button1" value="Button"
onclick="if (typeof(Page_Cl ientValidate) == 'function')
Page_ClientVali date();
if (Page_IsValid !=null && Page_IsValid == true)
DoSomethingIWan t();"
language="javas cript" id="Button1" />

If I override the Render() method, the buildin jscript always emitted. How
can I get the exactly I want above?

Thanks in advance.
Nov 19 '05 #1
2 2973
You can add an onclick event handler to the button like this:

Button1.Attribu tes.Add("onclic k", "if (Page_IsValid !=null && Page_IsValid
== true) DoSomethingIWan t();");

"Caspy" <ca******@yahoo .com> wrote in message
news:eH******** ******@TK2MSFTN GP15.phx.gbl...
When add a button to a web form, if the button can CauseValidation , the
server emits client side javascript as:
<input type="submit" name="Button1" value="Button"
onclick="if (typeof(Page_Cl ientValidate) == 'function')
Page_ClientVali date(); "
language="javas cript" id="Button1" />

What I want to let the emitted javascript like :
<input type="submit" name="Button1" value="Button"
onclick="if (typeof(Page_Cl ientValidate) == 'function')
Page_ClientVali date();
if (Page_IsValid !=null && Page_IsValid == true)
DoSomethingIWan t();"
language="javas cript" id="Button1" />

If I override the Render() method, the buildin jscript always emitted. How
can I get the exactly I want above?

Thanks in advance.

Nov 19 '05 #2
You approach generates something like:
<input type="submit" name="Button1" value="Button" onclick="if(Pag e_IsValid
== fasle) alert('Invalid! ');if (typeof(Page_Cl ientValidate) == 'function')
Page_ClientVali date(); " language="javas cript" id="Button1" />

The key point here is that (Page_IsValid == fasle) is checked before the
page is validated, which the Page_IsValid always true. This is not waht I
want.
"Raul Macias" <ra*********@ho tmail.com> wrote in message
news:u3******** ******@TK2MSFTN GP12.phx.gbl...
You can add an onclick event handler to the button like this:

Button1.Attribu tes.Add("onclic k", "if (Page_IsValid !=null && Page_IsValid
== true) DoSomethingIWan t();");

"Caspy" <ca******@yahoo .com> wrote in message
news:eH******** ******@TK2MSFTN GP15.phx.gbl...
When add a button to a web form, if the button can CauseValidation , the
server emits client side javascript as:
<input type="submit" name="Button1" value="Button"
onclick="if (typeof(Page_Cl ientValidate) == 'function')
Page_ClientVali date(); "
language="javas cript" id="Button1" />

What I want to let the emitted javascript like :
<input type="submit" name="Button1" value="Button"
onclick="if (typeof(Page_Cl ientValidate) == 'function')
Page_ClientVali date();
if (Page_IsValid !=null && Page_IsValid == true)
DoSomethingIWan t();"
language="javas cript" id="Button1" />

If I override the Render() method, the buildin jscript always emitted.
How can I get the exactly I want above?

Thanks in advance.


Nov 19 '05 #3

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

Similar topics

2
3424
by: Vinita Sharma | last post by:
Hi All, I have a strange problem. I have 2 text boxes and a button in my form. There is a function called on onchange event of the first text box. There is another function called on onclick event of the button. Things work fine if you move from one field to another using tab keys. But if you change something in the first text box and move to button using mouse, the onchange event of the text box is called but the onclick event of the...
2
18581
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } Which is called statically by: <button onclick="doClick(event,this);">Click me</button>
3
3811
by: f1crazed | last post by:
Hello, I am wanting to fire the onClick event of button1 by pressing button2. Does anyone have a clue if this is even posible? If so PLEASE HELP!! Thanks.
2
3383
by: jdph40 | last post by:
In Access 97, I have a form named frmEmpList with a list box that contains the names of all our employees. I have a command button with the following code in the OnClick event so the form will open showing only the record of the employee selected from the list: Dim varSelected As Variant Dim strSQL As String If IsNull(Me!) Then MsgBox "You must select an employee's name from the list.", vbExclamation, "NOTE"
5
2594
by: moondaddy | last post by:
I have a <a> element in a datagrid which wraps some asp.net labels. this element also has an onclick event which does not fire in netscape 6 (and perhaps other browsers for all I know...). Below is the code for this. the onclick event calls a javascript function which I put an alert in the firt line to tell me if its working. It does work in IE. Any ideas on how to get netcrap... oops, I'm sorry, netscape to fire the onclick event? ...
5
5851
by: kai | last post by:
Hi, In ASP.NET , what is the difference between OnClick and Click events for a button? Because we have button click event, it can trigger events, why we still need OnClick? Please help. Thanks kai
7
2795
by: extremerep | last post by:
My task is to change the value of a button and then make it functional with the onClick handler. Changing the value to "Play Again" works, but making the onClick work accordingly does not. The following is a snippet of the script. What is keeping it from working? function displaycards1(){ document.form1.reveal1.value="Play Again"; document.form1.reveal1.onClick="setcards();"; } </script>
5
13963
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 TextBox I want to use a hidden button to fire when the Onclick Event is fired for the TextBox.
3
6510
by: Michael_R_Banks | last post by:
I'm trying to dynamically build a table that allows users to remove rows when they click a corresponding button. For some reason, whenever I add the button to the table, it never fires the onclick event. I'm stumped with this one, any assistance would be appreciated. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"...
0
9672
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...
0
10435
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
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
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
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
6779
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();...
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.