i have a gridview.
there is a itemtemplet a TEXTBOX txt_name
i want to fetch this textbox text using javascript.
how can i do this.
how can i call that textbox of gridview using javascript
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dorababu MekaPosted Feb 4, 2012, 1:45 AM
protected void gvDetails_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TextBox txt = (TextBox)e.Row.FindControl("txt");
txt.Attributes.Add("onclick", "f1()");
}
}
I just write a simple javascript to alert hello in that f1()
alternative you can pass the control to function if needed
Dorababu MekaPosted Feb 4, 2012, 1:26 AM
txt.attributes.add("function(ex:onclick")","your JS function");
I am not sure about this but make a try