Hello,
I'm writing a usercontrol to be included in my project. The usercontrol
have a few javascript function to do the client-side tasks. However, the
controls on the usercontrol seems to change at execution(e,g: the TextBox
with id & name"txtbox" in usercontrol "folder1" will have name
"folder1:txtbox" and id "folder1_txtbox" during execution)
Since I'll use the control in many place inside my project, it's not
possible for me to hardcode their name. Could anyone suggest some way to
address the controls?
The first idea come up in my mind is to use document.getElementById().
But then I do not know how to gather the ID of the usercontrol itself.
Any help would be appreciated. Thank you.
Regards,
Lau Lei Cheong 5 5043
If you want to konw the exact name of the controll that gets sent out in the
HTML
use the ClientID propertiy.
it will return the folder1_txtBox value for you .
"Lau Lei Cheong" <la****@yahoo.com.hk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Hello,
I'm writing a usercontrol to be included in my project. The
usercontrol have a few javascript function to do the client-side tasks. However, the controls on the usercontrol seems to change at execution(e,g: the TextBox with id & name"txtbox" in usercontrol "folder1" will have name "folder1:txtbox" and id "folder1_txtbox" during execution) Since I'll use the control in many place inside my project, it's not possible for me to hardcode their name. Could anyone suggest some way to address the controls? The first idea come up in my mind is to use document.getElementById(). But then I do not know how to gather the ID of the usercontrol itself. Any help would be appreciated. Thank you.
Regards, Lau Lei Cheong
You can read up on the subject in this article: http://www.aspnetpro.com/features/20...200406so_f.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Lau Lei Cheong" <la****@yahoo.com.hk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... Hello,
I'm writing a usercontrol to be included in my project. The
usercontrol have a few javascript function to do the client-side tasks. However, the controls on the usercontrol seems to change at execution(e,g: the TextBox with id & name"txtbox" in usercontrol "folder1" will have name "folder1:txtbox" and id "folder1_txtbox" during execution) Since I'll use the control in many place inside my project, it's not possible for me to hardcode their name. Could anyone suggest some way to address the controls? The first idea come up in my mind is to use document.getElementById(). But then I do not know how to gather the ID of the usercontrol itself. Any help would be appreciated. Thank you.
Regards, Lau Lei Cheong
Oops, I do not have an account to login there.
Thank you anyway. :)
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g... You can read up on the subject in this article:
http://www.aspnetpro.com/features/20...200406so_f.asp
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Lau Lei Cheong" <la****@yahoo.com.hk> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... Hello,
I'm writing a usercontrol to be included in my project. The usercontrol have a few javascript function to do the client-side tasks. However, the controls on the usercontrol seems to change at execution(e,g: the
TextBox with id & name"txtbox" in usercontrol "folder1" will have name "folder1:txtbox" and id "folder1_txtbox" during execution) Since I'll use the control in many place inside my project, it's not possible for me to hardcode their name. Could anyone suggest some way to address the controls? The first idea come up in my mind is to use
document.getElementById(). But then I do not know how to gather the ID of the usercontrol itself. Any help would be appreciated. Thank you.
Regards, Lau Lei Cheong
I'll do more experiments on that. Thank you. :D
"Darren Clark" <dc******@hotmail.com> ¦b¶l¥ó
news:O8**************@tk2msftngp13.phx.gbl ¤¤¼¶¼g... If you want to konw the exact name of the controll that gets sent out in
the HTML
use the ClientID propertiy.
it will return the folder1_txtBox value for you .
After some experiment, I finally come up with this piece of code.
Not using ClientID, but it does do the job. :)
var ctlname = name.substr(0, name.search(/:/i));
document.getElementById(ctlname + 'mycontrol').value='newvalue';
I use name property instead of Id to address the control because colon
is not commonly used in name, while underscore in Id does commonly used
in Id.
Regards,
Lau Lei Cheong
"Lau Lei Cheong" <la****@yahoo.com.hk> ¦b¶l¥ó
news:Ob**************@tk2msftngp13.phx.gbl ¤¤¼¶¼g... I'll do more experiments on that. Thank you. :D
"Darren Clark" <dc******@hotmail.com> ¦b¶l¥ó news:O8**************@tk2msftngp13.phx.gbl ¤¤¼¶¼g... If you want to konw the exact name of the controll that gets sent out in the HTML
use the ClientID propertiy.
it will return the folder1_txtBox value for you .
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: balu |
last post by:
i created a user control for contact information. this control has
contact name country etc and also phone number. all these are text
boxes. My problem is for phone number i should give 3 text...
|
by: Carlo Marchesoni |
last post by:
I have a UserControl that builds a Tree-View Menu using Javascript. This UC does not run as a ServerControl
Then, in every aspx page I include this UC. Everything works perfect, except that if I...
|
by: Jimmy |
last post by:
Hi
How do you refer from you webpage to a usercontrol which contains a n html
control with javascript?
usercontrol contains:
<input id="tb1" name="tb1" type=text>
|
by: Joe |
last post by:
Hello All:
Do I have to use the LoadControl method of the Page to load a UserControl?
I have a class which contains three methods (one public and two private).
The class acts as a control...
|
by: tshad |
last post by:
I get an error when running my Javascript inside my UserControl. It works
fine if I put the UserControl Data directly in my Web Page.
The stripped down code is:
<script language=javascript>...
|
by: Italian Pete |
last post by:
Hi,
I have a usercontrol which includes a small piece of Javascript built up
as a string in <scripttags and put onto a web page when an instance of the
User Control is created. The Javascript does...
|
by: acadam |
last post by:
Hi,
I have an userControl .ascx with a gridView control. One of the columns
is a TemplateField with an HyperLink control. On the Row_DataBound
event, I am checking that one of the other columns...
|
by: Jesper Lund Stocholm |
last post by:
I have problems with sending javascript to the client from a dynamically
loaded usercontrol.
I have a single page that dynamically loads controls into a table cell in
a HTML-table. For one of...
|
by: jyanmin.fang |
last post by:
Hi,
In my current project, I need to embed an .NET winform usercontrol in
the aspx page (via <Objecttag). This winform usercontrol has an
event called DoEvent (void DoEvent()). This winform...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |