Control ID Name

  • Thread starter OldButStillLearning
  • Start date
O

OldButStillLearning

I want to write some javascript attached to some event. When the event
fires, I want to pass the name of a ASP.Net Control to the javascript. I
happen to be working in a web page which has a master page. What I notice is
that when the page is rendered the ID's of all of the ASP.Net controls are
altered with what appears to be a prefix. How can I know the ID name so that
my javascript can do a "document.getElementById(controlIDName)"?
 
B

bruce barker

var ctl = document.getElmentById('<%= myControl.ClientID %>');

-- bruce (sqlwork.com)
 
G

grava

OldButStillLearning said:
I want to write some javascript attached to some event. When the event
fires, I want to pass the name of a ASP.Net Control to the javascript. I
happen to be working in a web page which has a master page. What I notice
is
that when the page is rendered the ID's of all of the ASP.Net controls are
altered with what appears to be a prefix. How can I know the ID name so
that
my javascript can do a "document.getElementById(controlIDName)"?

Well,

if you're writing javascript code directly in the aspx page you can use
something like this:

....
<asp:textbox id="txtBox" runat="server" .../>

...

<script language="javascript" type="text/javascript">
var clientVisibleTextBox =
document.GetElementById('<%=txtBox.ClientId%>');
...
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top