473,387 Members | 1,575 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,387 software developers and data experts.

.net Control id and javascript problem

Hi,

I 've tried to work around with this long times ago.
I have a template and the page loaded inside.
When loading the page,the control ID contained with the page
will be automatically generated by ASP.NET as shown below

<input name="_PageTemplate:BodyPlaceHolder:txtEndDate"
id="_PageTemplate_BodyPlaceHolder_txtEndDate" type="hidden" value="15
May 2005 23:59:59" />

How could I use javascript to grab data from each control.
I can't access it through "document.form.txtEndDate.value"
Because, It said txtEndDate is undefined.

Any idea would be appreciated!

Regards
Nov 16 '05 #1
2 1271
Hi,

You can loop thru the document element list and find for the control you
want to work with. Like here you can check whether you have the element name
ending with txtEndDate. A bit of js string manipulation is required.

Hope this helps.

Ganesh

"sarunnio" wrote:
Hi,

I 've tried to work around with this long times ago.
I have a template and the page loaded inside.
When loading the page,the control ID contained with the page
will be automatically generated by ASP.NET as shown below

<input name="_PageTemplate:BodyPlaceHolder:txtEndDate"
id="_PageTemplate_BodyPlaceHolder_txtEndDate" type="hidden" value="15
May 2005 23:59:59" />

How could I use javascript to grab data from each control.
I can't access it through "document.form.txtEndDate.value"
Because, It said txtEndDate is undefined.

Any idea would be appreciated!

Regards

Nov 16 '05 #2
In/after the prerender phase (lookup "ASP.NET life cycle") you will be
able to get a client-side reference to a control using its ClientID.

See http://wilcoding.xs4all.nl/wilco/View.aspx?NewsID=144 for more
information and source code where this is used.

----
- Wilco Bauwer
Blog & Custom Controls @ http://wilcoding.xs4all.nl

Nov 16 '05 #3

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

Similar topics

8
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3"...
1
by: mjcast | last post by:
I have been working on an ActiveX control in C#. It is packaged in a Windows Control library and the code is in a user control. The control is used as an automation receiver that is used to update a...
4
by: Barb | last post by:
I have a user control as my Save button for my page. When the Save button is clicked, I want some client-side validation to take place from a javascript function in the page, and then I'd like the...
2
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
1
by: Jorge Ponte | last post by:
hi I have a Web User Control (ascx) - lets call it "My_WUC" - in a Web form. In that WUC I want have a textbox and a button. I want to click on the button and open a popup (I use javascript for...
4
by: Neil Stevens | last post by:
Hi, Merry Christmas to you all. I have a problem with server controls, i am writing a C# ASP.NET web project and i am creating custom server controls for some of the more common element. One...
4
by: Marius Trælnes | last post by:
Hello! I am about to make a class/control that creates tabbing functionality. The result is in HTML/CSS/JavaScript output. My question is: Within the tabs I want to simply add user controls...
1
by: john conwell | last post by:
I'm using the Browser control to display html that my application generates. Some times i want a javascript to run when the html gets displayed in the browser control, and sometimes i dont. Is...
1
by: rn5a | last post by:
I have created a custom control button which when clicked displays a message in the JavaScript alert dialog. I could successfully compile the VB class file into a DLL & also could add it to the...
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
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: 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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
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,...
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,...

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.