Solved

javascript search control by partial name

Posted on 2009-04-08
3
1,569 Views
Last Modified: 2013-11-19
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
Comment
Question by:ammarg52
3 Comments
 
LVL 9

Accepted Solution

by:
Sreedhar Vengala earned 500 total points
ID: 24096484
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
 
LVL 9

Expert Comment

by:AsishRaj
ID: 24112867
var hiddenControl = '<%= txtFirstName.ClientID %>';
        document.getElementById(hiddenControl).value=assign new value

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now