Trying to hide a text box using the below script:
function EnableTextBox(clientId2, clientId1) {
var label = eval("document.getElementById('" + clientId2 + "')");
var textBox = eval("document.getElementById('" + clientId1 + "')");
if (label.Visible == true) {
label.Visible = false;
textBox.Visible = true;
}
else {
label.Visible = true;
textBox.Visible = false;
}
}
The text box is in the same cell as a label, and the event is created in the code behind during the gridview_ondatabound event:
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblNotes = (Label)(e.Row.Cells[1].Controls[1]);
TextBox tbNotes = (TextBox)(e.Row.Cells[1].Controls[3]);
if (lblNotes != null)
{
lblNotes.Attributes.Add("methodstring", string.Format("EnableTextBox('{0}', '{1}')", lblNotes.ClientID, tbNotes.ClientID));
lblNotes.Attributes.Add("onClick", "eval(this.methodstring)");
}
}
The problem I haven't gotten around yet is that the variable tbNotes in my script remains in a null state. Any suggestions?
Thanks