Event?
Event means action. When user click a button means user wants to perform an action. Events like performing:
List of available javascript Events are given below:*To see the example scroll down
Add the handler:
Event means action. When user click a button means user wants to perform an action. Events like performing:
- Click on a button
- Press a key
- Highlight text
- Drag & Drop
List of available javascript Events are given below:*To see the example scroll down
Event | Description | Applicable for ? |
onAbort | When user cancel image loading | Image |
onBlur | When control lost its Focus | Button, Checkbox, FileUpload, Layer, Password, Radio, Reset, Select, Submit, Text, TextArea, Window |
onChange | Combo index change/Textbox data change | Text, TextArea, Select |
onClick | Most useful event. Occur when user click on a button | Button, Checkbox, Link, Radio, Submit |
onDblClick | When user double click on a Link | Link |
onFocus | When an object get focus | Button, Checkbox, Radio, Reset, Select, Submit, Text, TextArea |
onKeyDown | When the key is down means pressing time | Link, TextArea |
onKeyPress | When user presses/holds a key | Link, TextArea |
onKeyUp | When user release a key | Link, TextArea |
onLoad | After completion of loading a page | Window, Image |
onMouseDown | When mouse presses | Link, Button, Document |
onMouseMove | When user moves the mouse | Link, Button, Document |
onMouseOut | When user moves the mouse away from a object | Image, Link |
onMouseOver | When user moves the mouse over a object | Image, Link |
onMouseUp | When user release mouse | Document, Button, Link |
onMove | When user moves the browser window or a frame | Document, Button, Link |
onReset | By clicking on reset Button | Form |
onResize | When user resizes the browser window or a frame | Window |
onSelect | When user select text | Text, TextArea |
onSubmit | When user clicks the submit button | Form |
onUnload | When user leaves the page/close the browser | Window |
Example onClick Event:
Here i am showing how one can use this event & add event handler. Example covers both asp.net server side control & HTML control. To run this example just copy the below code then run your page. Add the below function in your javascript block:
Here i am showing how one can use this event & add event handler. Example covers both asp.net server side control & HTML control. To run this example just copy the below code then run your page. Add the below function in your javascript block:
function funcOnClick()
{
// Code goes here
alert("Click event fired");
// Return false never make a post back to server.
// so one can add validation by using this concept. If return true then the page will be post back to server
return false;
}
{
// Code goes here
alert("Click event fired");
// Return false never make a post back to server.
// so one can add validation by using this concept. If return true then the page will be post back to server
return false;
}
Add the handler:
<asp:button runat="server" id="cmdOnClick" text="OnClientClick" onclientclick="return funcOnClick();">
<asp:button runat="server" id="cmdOnClick" text="OnClientClick" onclientclick="return funcOnClick();">
<asp:button runat="server" id="cmdRunTime" text="Server Control onClick">
<input type="button" name="cmdHTML" value="HTML onClick" onclick="return funcOnClick();">
<asp:button runat="server" id="cmdOnClick" text="OnClientClick" onclientclick="return funcOnClick();">
<asp:button runat="server" id="cmdRunTime" text="Server Control onClick">
<input type="button" name="cmdHTML" value="HTML onClick" onclick="return funcOnClick();">
No comments:
Post a Comment