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

In DNN getElementById cant find control

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Declan
Top achievements
Rank 2
Declan asked on 01 Oct 2008, 04:50 PM
I am using RadGrid in a DotNetNuke module and am trying to access a check box within an edit form template on the grid on the client, without success.

If I put a check box outside the grid I can access it without difficulty.

Normally I would access controls on a form on the client side using something like:

var gridControl = document.getElementById("<%= grd.ClientID %>");
alert(gridControl.id);

This works for the grid and if I use something similar with a check box outside the grid it also works.

var cb= document.getElementById("<%= myCheckBox.ClientID %>");
alert(cb.id);

How can I access the check box within the edit form of a rad grid? The checkbox does not exist in the Item template only the edit item template.

A sample would be appreciated.

Declan

1 Answer, 1 is accepted

Sort by
0
Declan
Top achievements
Rank 2
answered on 01 Oct 2008, 07:51 PM
This works but not very elegant!
function TestCheckBox()  
    { 
    var gridControl = document.getElementById("<%= grd.ClientID %>"); 
    var Inputs = gridControl.getElementsByTagName("input"); 
 
    for (var n = 0; n < Inputs.length; ++n) 
        if (Inputs[n].type == 'checkbox')  
            { 
                if (Inputs[n].id.indexOf('chkBox') > 0 && Inputs[n].checked)  
                    { 
                        var message = "Some message text.\n" + 
                        "Click OK to continue or Cancel to change your selection.\n" 
                        if (!confirm(message)) return false
                            return true
                    } 
            } 
    } 

Tags
Grid
Asked by
Declan
Top achievements
Rank 2
Answers by
Declan
Top achievements
Rank 2
Share this question
or