ComponentOne Input for ASP.NET AJAX: Client-Side Functionality > Client-Side Events

Client-Side Events

Input for ASP.NET AJAX includes a rich client-side object model with several client-side events.

To add a handler for a client-side event, click one of the OnClient properties in the Visual Studio Properties window. A drop-down list appears with a list of JavaScript functions currently defined on your Web form and the option to add a new event handler.

 

 

When you select Add New Client Side Handler from the drop-down list, a new JavaScript function base will automatically be generated for you and added to your Web form.

Your screen will automatically change to Code view and highlight the new function. For example, the new client-side handler for OnClientInvalidInput generates the following:

function C1MaskedInput1_OnClientInvalidInput(aC1Edit)

{

// Put you code here.

};

You can then write code to handle the event.

Client-side event example

Here is an example of the OnClientKeyDown event handler:

<script type="text/javascript">

// Set numeric range to 0001 on ctrl+home

// Set numeric range to 0999 on ctrl+end

function do_OnClientKeyDown(aC1Edit, aKeyCode, aEvent){

 if(aEvent.ctrlKey) {

   if(aKeyCode == 36) { // if Home key down

     aC1Edit.set_Text("0001");

     aC1Edit.selectText(3);//set caret to new position

   }

   if(aKeyCode == 35) { // if End key down

     aC1Edit.set_Text("0999");

     aC1Edit.selectText(1, 4);//select text '999'

   }

 }

};

</script>

<cc1:C1MaskedInput

  id="C1MaskedInput1"

  runat="server"

  mask="<<0...1000>>"

  onclientkeydown="do_OnClientKeyDown"

  text="0009">

</cc1:C1MaskedInput>

The following provides names and descriptions of Input for ASP.NET AJAX's client-side events:

 

Event Property

Client-Side Equivalent Methods

Description

Parameter

OnClientBlur

get_OnClientBlur, set_OnClientBlur(func_name)

Occurs when the control loses the input focus.

aC1Edit

OnClientCustomButtonClick

get_OnClientCustomButtonClick, set_OnClientCustomButtonClick
(func_name)

Occurs when the user clicks a custom button.

aC1Edit

OnClientDateChanged

get_OnClientDateChanged, set_OnClientDateChanged(func_name)

Occurs when the user changes the Date value.

aC1Edit

OnClientFocus

get_OnClientFocus, set_OnClientFocus(func_name)

Occurs when the control receives focus.

aC1Edit

OnClientInit

get_OnClientInit, set_OnClientInit(func_name)

Occurs when the control is initialized.

aC1Edit

OnClientInvalidInput

get_OnClientInvalidInput, set_OnClientInvalidInput(func_name)

Occurs when the user enters invalid input in the control.

aC1Edit

OnClientKeyDown

get_OnClientKeyDown, set_OnClientKeyDown(func_name)

Occurs when the user presses a key.

aC1Edit, aKeyCode, aEvent

OnClientKeyPress

get_OnClientKeyPress, set_OnClientKeyPress(func_name)

Occurs when the user presses an alphanumeric key.

aC1Edit, KeyCode, aEvent

OnClientKeyUp

get_OnClientKeyUp, set_OnClientKeyUp(func_name)

Occurs when a user releases a key.

aC1Edit, aKeyCode, aEvent

OnClientMouseDown

get_OnClientMouseDown, set_OnClientMouseDown(func_name)

Occurs when the user clicks the control with either mouse button.

aC1Edit, aEvent

OnClientMouseOut

get_OnClientMouseOut, set_OnClientMouseOut(func_name)

Occurs when the user moves the mouse pointer outside the boundaries of the control.

aC1Edit, aEvent

OnClientMouseOver

get_OnClientMouseOver, set_OnClientMouseOver(func_name)

Occurs when the user moves the mouse pointer into the control.

aC1Edit, aEvent

OnClientMouseUp

get_OnClientMouseUp, set_OnClientMouseUp(func_name)

Occurs when the user releases a mouse button while the mouse pointer is over the control.

aC1Edit, aEvent

OnClientTextChanged

get_OnClientTextChanged, set_OnClientTextChanged(func_name)

Occurs when the user changes text in the control.

aC1Edit

OnClientValueBoundsExceeded

get_OnClientValueBoundsExceeded, set_OnClientValueBoundsExceeded (func_name)

Occurs immediately after the value typed in the input box is out of Min or Max bounds.

aC1Edit

 

For examples showing common client-side tasks, see the Client-Side Event Tasks topic.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.