473,395 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Replacing <%= Control.ClientID %> in external javascript

Hi,

I have an aspx with a control on it, lets call it myControl, and I have an
external javascript file.

In the external javascript file, I have

var myControlId = '<%=myControl.ClientID%>';

which would work fine if the javascript was in the .aspx file, but when
adding the external javascript file via
Page.ClientScript.RegisterClientScriptInclude, the myControl.ClientID does
not get replaced with the client id.

I'm sure I've seen a way to do this before, can someone point me in the
right direction?

Thanks
Mark

Jan 22 '08 #1
1 5999
On Tue, 22 Jan 2008 10:31:59 -0500, "MarkShoe"
<ma*******@community.nospamwrote:
>Hi,

I have an aspx with a control on it, lets call it myControl, and I have an
external javascript file.

In the external javascript file, I have

var myControlId = '<%=myControl.ClientID%>';

which would work fine if the javascript was in the .aspx file, but when
adding the external javascript file via
Page.ClientScript.RegisterClientScriptInclude, the myControl.ClientID does
not get replaced with the client id.

I'm sure I've seen a way to do this before, can someone point me in the
right direction?
As you have found out the ClientIDs need to added to script. I suggest
the myControl type dynamically generate and register its own scripts.
If include files are to be used let the control read the file and
programmatically replace the tagged elements with ClientIDs before
registering the script. The dependencies between the script and the
control might justify the functionality all be in one wrapper.

regards
A.G.

Jan 22 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
10
by: Wayne Wengert | last post by:
Is there a way for ASP.NET/VB codebehind to get the contents of a plain old <textarea> element? I added an id='myname' to the <textarea> tag but VSNET complains that it is undefined? Wayne
29
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
39
by: eruanion | last post by:
Hi, I've been working on this for a while now and I can't seem to find out what is wrong with my code. I have 2 files one c3common.js which only contains javascript functions for my main html page...
7
by: Alex Maghen | last post by:
I have some client-side JavaScript that I want to run whenever a pulldown <SELECT> is changes on th client. I'm trying to do this as follows... <select id="MyPulldown"...
5
by: Alex Maghen | last post by:
I frequently find myself wanting to insert some basic client-side JavaScript functions in the page of an ASPX of mine. But I find it so frustrating that I have to actually contruct my JavaScript in...
3
by: henk | last post by:
Hey, Question, how can i create client-side javascript that refers to a asp.net webcontrol. For example set the focus of a textbox lik this. <asp: TextBox ID="Textbox1" /> (client side)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.