This is a migrated thread and some comments may be shown as answers.

EditForm RegisterStartupScript

2 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 14 Feb 2012, 07:05 PM
Is it possible to set a startup script for a Edit Form template of an RadGrid? If so how? 

I would like to set a javascript function for the ScriptManager.RegisterStartupScript() like I can do for a RadWindow in the Page_Load() event but I'm unable to locate anything on how to do it. I have the need to access specific html table cell styles to change the background color of the Edit Form template.

Any help would be appreciated.
-Richard

2 Answers, 1 is accepted

Sort by
0
Accepted
Elliott
Top achievements
Rank 2
answered on 14 Feb 2012, 10:02 PM
on the Item Created event
check the item is in edit mode
        If e.Item.IsInEditMode Then
        Else
            Exit Sub
        End If
        If TypeOf e.Item Is GridEditableItem Then
        Else
            Exit Sub
        End If
' insert
        If TypeOf e.Item Is IGridInsertItem Then
            If txtPartNumber Is Nothing Then
            Else
                txtPartNumber.Focus()
            End If
        Else
            txtPartNumber.ReadOnly = True
            rntbQty.Focus()
        End If

at this point find and decorate your cells
        Dim geItem As GridEditableItem = Nothing
        Dim tcPartNumber, tcQty As TableCell
        Dim txtPartNumber As TextBox
        Dim rntbQty As RadNumericTextBox
        Dim btnUpdate As LinkButton
        Dim sb As StringBuilder = Nothing
......     
        btnUpdate = DirectCast(geItem.FindControl("btnUpdate"), LinkButton)
        tcQty = geItem.Cells(1)
        rntbQty = tcQty.FindControl("rntbQty")
        If rntbQty Is Nothing Then
        Else
            sb = New StringBuilder("if(event.which || event.keyCode)")
            sb.Append("{if ((event.which == 13) || (event.keyCode == 13)) ")
            sb.Append("{document.getElementById('")
            sb.Append(btnUpdate.ClientID)
            sb.Append("').click();return false;}} ")
            sb.Append("else {alert(keyCode);return true};")
            rntbQty.Attributes.Add("onkeydown", sb.ToString)
        End If
        If TypeO
0
Richard
Top achievements
Rank 1
answered on 14 Feb 2012, 11:38 PM
Thanks for the quick reply Marianne. This was very helpful.
Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
Richard
Top achievements
Rank 1
Share this question
or