Click here to Skip to main content
15,918,041 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hello friends,
I am sending string type TextBox control id from code behind to javascript function. I need to find the textBox object in javascript in which i can use .focus() method
how to get this ?
Posted
Comments
Thanks7872 23-Feb-15 7:09am    
How? You know the method. Get it. What is the problem doing so?

You need not send it nowhere - use inline server tags...
JavaScript
<script>
  var el = document.getElementById('<%= MyTextBox.ClientID %>');

  if(el) el.focus();
</script>
 
Share this answer
 
Comments
rhl4569 23-Feb-15 7:27am    
it is not working sir.. how to use this method if MyTextBox id is stored in var some variable. and how to use that variable in place of MyTextBox.ClientID ????
Kornfeld Eliyahu Peter 23-Feb-15 7:34am    
In what variable? A JavaScript variable?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900