Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid link button click event in clientside

Reply
Thread Tools

Datagrid link button click event in clientside

 
 
Niclas Lindblom
Guest
Posts: n/a
 
      06-26-2004
Hi,

I have a datagrid with linkbuttons. I would like to catch the click event
when a link button has been clicked and use the string from the text value
of the link button in a clientside Java script. Is this possible or should I
look for other ways of achieving this ?

Regards

Niclas


 
Reply With Quote
 
 
 
 
Rick Spiewak
Guest
Posts: n/a
 
      06-27-2004
This is possible. Here is a related example, which uses the onclick event of
a checkbox:

// Enable or disable the one or more validation control(s), based on the
state of the calling control.
// The calling control is an ASP.NET control which is a child control
within a DataGridItem or equivalent,
// using the onclick event on the client. This implementation assumes that
the calling control is a checkbox.
//
// Author: Rick Spiewak, 6/23/2004
//
// Usage:
// In the HTML of the .aspx page, reference this file:
//
// <script language="javascript" src="[relative path to this file:
Utilities.js]" ></script>
//
// Example of use during the ItemCreated event:
// Dim itm As DataGridItem = e.Item
// Dim enableValidation As String =
"enableValidation(this,'valManifestNo, valAnotherControl');"
// Select Case itm.ItemType
// Case ListItemType.Item, ListItemType.AlternatingItem
// Dim cb As CheckBox =
DirectCast(itm.FindControl("chkReceive"), CheckBox)
// cb.Attributes.Add("onclick", enableValidation)
// End Select
//
// Parameters:
// ctrl a datagrid item (or similar) child control. Currently, this must
be a checkbox.
// The name is parsed to find the line prefix.
// validator the ASP.NET ID (string) of the validation control(s) to be
enabled or disabled
// This can be a comma-separated list.
function enableValidation(ctrl, validator)
{
validator = validator.replace(" ","");
var i = validator.indexOf(",");
// Handle the case where "validator" is a comma-separated list by
recursion.
if (i > -1) {
var valArray;
var j;
valArray = validator.split(",");
for (j = 0; j < valArray.length; j++) {
enableValidation(ctrl,valArray[j]);
}
return(0);
}
if (validator.length < 2){return(0);}

var ID = ctrl.id;
i = ID.indexOf("__");
i = ID.indexOf("_", i + 2);
var validatorID = ID.substring(0,i) + "_" + validator;
// The validator is in a span, potentially in a different table cell
// the parentElement is a <td>, its parent is the <tr>
var spans =
ctrl.parentElement.parentElement.getElementsByTagN ame("span");
// Find the validator for *this* item among the spans
// currently only implemented for checkbox controls as the input
control
for (i = 0; i < spans.length; i++) {
var val = spans[i];
if (val.id == validatorID) {
// Set the initial state as enabled, then call the standard
validation
// function to get the correct value of .isvalid
val.setAttribute("enabled",true);
ValidatorValidate(val);
// If the checkbox is checked and the validator isn't valid,
then show the error
val.style.visibility = (ctrl.checked && !val.isvalid) ?
"visible" : "hidden";
val.setAttribute("enabled",ctrl.checked);
break;
}
}
}
"Niclas Lindblom" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have a datagrid with linkbuttons. I would like to catch the click event
> when a link button has been clicked and use the string from the text value
> of the link button in a clientside Java script. Is this possible or should

I
> look for other ways of achieving this ?
>
> Regards
>
> Niclas
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Datagrid Control 0 05-25-2004 01:45 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Web Controls 0 05-25-2004 01:45 AM



Advertisments