[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1583
  • Last Modified:

javascript search control by partial name

I am using javascript and asp.net. I have control by id "txtFirstName" inside template in the grid. aspnet wraps this control by id "ctl00_ContentPlaceHolder1_txtFirstName". I have many pages and multiple templates in my web app. I am looking for solution as to give "txtFirstName" as paarameter to the javascript function and thefunction should find the control with in the page. In this case it is "ctl00_ContentPlaceHolder1_txtFirstName".
0
ammarg52
Asked:
ammarg52
1 Solution
 
Sreedhar VengalaCommented:
frm = window.document.form1

for ( var f = 0; f < frm.elements.length; ++f )
{
// get one element
var ele = frm.elements[f];
// see if it is one of our txtFirstName element
      if ( ele.name.substring(ele.name.length - 12) == "txtFirstName" )
      {
            // code...
      }
}
0
 
AsishRajCommented:
var hiddenControl = '<%= txtFirstName.ClientID %>';
        document.getElementById(hiddenControl).value=assign new value

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now