PC Review


Reply
Thread Tools Rate Thread

Control ID Name

 
 
OldButStillLearning
Guest
Posts: n/a
 
      16th Jan 2008
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)"?
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      16th Jan 2008

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

-- bruce (sqlwork.com)


"OldButStillLearning" wrote:

> 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)"?

 
Reply With Quote
 
grava
Guest
Posts: n/a
 
      16th Jan 2008


"OldButStillLearning" <(E-Mail Removed)> wrote
in message news:1215B07C-3FCD-44B9-AEAF-(E-Mail Removed)...
> 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>


--
Gianluca Gravina
http://blogs.ugidotnet.org/thinkingingrava

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make a control show inherited events from System.Windows.Forms.Control Ralph Krausse Microsoft Dot NET Framework Forms 1 13th Nov 2004 09:21 PM
Compile errors when using form control's "Control Source" property to refer to the control's value Yarik Mezheritskiy Microsoft Access Form Coding 3 5th Nov 2004 01:56 AM
Showing 1 control inside a 2nd control where the 2nd control is a derived control. malcolm Microsoft Dot NET Framework Forms 0 10th Jun 2004 10:29 PM
Combo Box Control - CONTROL tab missing from FORMAT CONTROL dialogue =?Utf-8?B?QWw=?= Microsoft Excel Worksheet Functions 1 11th Mar 2004 06:47 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com Microsoft ASP .NET 0 1st Jul 2003 10:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:19 PM.