In RadGrid, I'm using a FormTemplate. I need to use javascript on the FormTemplate controls when in edit mode. I couldn't find a way to tie events within the FormTemplate in the aspx page, so I'm assigning them in the grid's ItemCreated event, like so...
| If (TypeOf e.Item Is GridEditFormItem) AndAlso (e.Item.IsInEditMode) Then |
| Dim item As GridEditFormItem = CType(e.Item, GridEditFormItem) |
| Dim chkName As CheckBox = CType(item.FindControl("chkName"), CheckBox) |
| Dim txtResult As RadTextBox = CType(item.FindControl("txtResult"), RadTextBox) |
| chkName.Attributes("onclick") = "NameChange('" & chkName.ClientID & "', '" & txtResult.ClientID & "');" |
| End If |
Then in the client-side, the function looks something like the following...
| function NameChange(chkNameClientID, txtResultClientID) { |
| var chkName = document.getElementById(chkNameClientID); |
| var txtResult = $find(txtResultClientID); |
| if (chkName.checked == false) { |
| txtResult.set_value('Joker'); |
| } else { |
| txtResult.set_value('Batman'); |
| } |
| } |
It works, but it seems a bit goofy to assign all my javascript calls on the server-side, pass all relevant ClientIDs and assign them to vars before working with them. So I'm wondering if this is the best way to do it, or if you recommend a different method and I'm going about it the hard way. Thanks.
