Intersoft WebGrid Documentation
OnButtonClick Property
See Also  Example Send Feedback
ISNet.WebUI.WebGrid Namespace > ClientEvents Class : OnButtonClick Property






Specifies the client side (JavaScript) function that will be invoked when button cell is clicked.

Syntax

Visual Basic (Declaration) 
<ISNet.Serialization.XmlSerializableAttribute()>
<ISNet.Serialization.BinarySerializableAttribute()>
<EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="ISNet.WebUI.Design.ClientSideEventEditor, ISNet.WebUI.Design")>
<NotifyParentPropertyAttribute(True)>
<ISNet.EventParameterAttribute("controlId, tblName, colName, cellValue")>
<DescriptionAttribute()>
<DefaultValueAttribute()>
Public Property OnButtonClick As String
Visual Basic (Usage)Copy Code
Dim instance As ClientEvents
Dim value As String
 
instance.OnButtonClick = value
 
value = instance.OnButtonClick
C# 
[ISNet.Serialization.XmlSerializableAttribute()]
[ISNet.Serialization.BinarySerializableAttribute()]
[EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="ISNet.WebUI.Design.ClientSideEventEditor, ISNet.WebUI.Design")]
[NotifyParentPropertyAttribute(true)]
[ISNet.EventParameterAttribute("controlId, tblName, colName, cellValue")]
[DescriptionAttribute()]
[DefaultValueAttribute()]
public string OnButtonClick {get; set;}
Delphi 
public read-write property OnButtonClick: String; 
JScript 
ISNet.Serialization.XmlSerializableAttribute()
ISNet.Serialization.BinarySerializableAttribute()
EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="ISNet.WebUI.Design.ClientSideEventEditor, ISNet.WebUI.Design")
NotifyParentPropertyAttribute()
ISNet.EventParameterAttribute("controlId, tblName, colName, cellValue")
DescriptionAttribute()
DefaultValueAttribute()
public function get,set OnButtonClick : String
Managed Extensions for C++ 
[ISNet.Serialization.XmlSerializableAttribute()]
[ISNet.Serialization.BinarySerializableAttribute()]
[EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="ISNet.WebUI.Design.ClientSideEventEditor, ISNet.WebUI.Design")]
[NotifyParentPropertyAttribute(true)]
[ISNet.EventParameterAttribute("controlId, tblName, colName, cellValue")]
[DescriptionAttribute()]
[DefaultValueAttribute()]
public: __property string* get_OnButtonClick();
public: __property void set_OnButtonClick( 
   string* value
);
C++/CLI 
[ISNet.Serialization.XmlSerializableAttribute()]
[ISNet.Serialization.BinarySerializableAttribute()]
[EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="ISNet.WebUI.Design.ClientSideEventEditor, ISNet.WebUI.Design")]
[NotifyParentPropertyAttribute(true)]
[ISNet.EventParameterAttribute("controlId, tblName, colName, cellValue")]
[DescriptionAttribute()]
[DefaultValueAttribute()]
public:
property String^ OnButtonClick {
   String^ get();
   void set (    String^ value);
}

Property Value

Returns return value.

Example

The sample below shows you how to display a message box showing the column name and the customer ID.
C#Copy Code
WebGrid1.LayoutSettings.ClientSideEvents.OnButtonClick = "WebGrid1_ButtonClick";
The following is the example of the javascript function that is assigned in above event.
JScriptCopy Code
function WebGrid1_ButtonClick(gridId, tblName, colName, cellValue) 
 {
   alert("Clicked button is : " + colName + "\nThe value is : " + cellValue);
   
   // set return false to cancel postback
   return true;
 }

Remarks

The user-defined function should only contain the name of the function. For example, "HandleEvent". This event allow developers to easily capture the button click event and process implementation further. Button ColumnType now has ability to perform postback to server automatically by setting the ButtonAutoPostBack to True. You can even choose whether the postback would be performed using OnTheFly(tm) postback for fast response or FullPageRefresh. This setting can be found in ButtonPostBackMode property. When ButtonAutoPostback is set to True, the ButtonClick server event will be invoked as well for both PostBackMode. You can cancel postback to occur by setting the return to false in this event.

The function can be defined in either inline or linked JavaScript files and can accept following parameters:

gridId

The ID of the grid calling the function.

tblName

The table name of the clicked button.

colName

The column name of the clicked button.

cellValue

The button cell's value. This value is available for Bound column and DataMember is specified.

Note that you should include the return value of your function. Returning a true value means that default behavior will be processed. Otherwise, the default behavior will be skipped.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.