J
Jonathan Levine
Hi,
I am trying to access the value of a text box in a DataGrid from inside JavaScript. I have tried the following:
void Item_Created(object sender, DataGridItemEventArgs e)
{
Button b = ((Button)e.Item.FindControl("AddUserButton"));
TextBox t = ((TextBox)e.Item.FindControl("Textbox"));
string onclick = "if(document.getElementById('" + t.ClientID + "').value != \"\") {";
//(extra stuff removed)
b.Attributes.Add("onclick", onclick);
}
However, the JavaScript generated is
if(document.getElementById('Textbox').value != "" {
This is strange, as the item itself has an ID of MyPage1:UserGrid:_ctl3:Textbox
I hope someone can help me with this.
Thanks,
I am trying to access the value of a text box in a DataGrid from inside JavaScript. I have tried the following:
void Item_Created(object sender, DataGridItemEventArgs e)
{
Button b = ((Button)e.Item.FindControl("AddUserButton"));
TextBox t = ((TextBox)e.Item.FindControl("Textbox"));
string onclick = "if(document.getElementById('" + t.ClientID + "').value != \"\") {";
//(extra stuff removed)
b.Attributes.Add("onclick", onclick);
}
However, the JavaScript generated is
if(document.getElementById('Textbox').value != "" {
This is strange, as the item itself has an ID of MyPage1:UserGrid:_ctl3:Textbox
I hope someone can help me with this.
Thanks,