Find Gridview TextBox in client side using javascript


How to find GridView Textbox in client side using java script

Find Gridview TextBox value in client side using javascript.

Here this article show show how we can find gridview textbox which is in Template Field.This code validate the Gridview textbox in edit mode.


function ValidateGridEditMode()
{
var n = document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvEmp').rows.length;
var i;
for(i=2; i <=n; i++)
{
if(i<10)
{
txtEmpName=document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvEmp_ctl0'+i+'_txtEmpName');
}
else
{
txtEmpName=document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvEmp_ctl'+i+'_txtEmpName');
}
if(txtEmpName !=null)
{
if(txtEmpName.value == "")
{
alert("Enter Emp Name...!");
txtEmpName.focus();
return false;
}
}
}

return true;
}


Reference: http://aspdotnetcode.blogspot.com


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: