tags:

views:

26

answers:

1

Hai,

I have a checkbox(chkVerified) control in a gridview. This is inside templatefield. I am checking the value of this checkbox in javascript. I am setting the visibility of this template field column through c# based on certain conditions. The issue is that, when the visibility of template field column is false, I am getting javascript error "Object Required" for the checkbox(chkVerified) control inside the template field I specified above. How can I avoid this error? I have to keep the javascript checking for checkbox(chkVerified) as it is needed in some other conditions. Help me.

A: 

You can check the Checkbox with null and proceed the JavaScript. You can easily check whether the CheckBox exists or not using the below script.

var chkBox = document.getElementById(chkVerified);
if(null != chkBox){
 // proceed the code CheckBox in Visible = true condition
}
else{
 // Proceed the code CheckBox in Visible = false condition
}

By using above, the you can avoid "Object Required" error in JavaScript.

Selva TS