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

getElementById question

Hello,
I have one button in the aspx page called btnSubmit which i need to disable
using javascript
the document.getElementById("btn_Submit").Enabled=fals e returns an error
and the
document.getElementById('_ctl0_ContentPlaceHolder1 _btnSubmit').Enabled=false
works fine but how can i get that _ctl0_ContentPlaceHolder1_btnSubmit' ? now
i looked in the "view source" of the actual page

thanks,
akis
Feb 20 '06 #1
5 3280
You can get the ID of the control on the clientside via the ClientID property
of the control. So when you render the script in your code do it in this way:
document.getElementById('" + myControl.ClientID + "');

At least this works for me.
"akis" wrote:
Hello,
I have one button in the aspx page called btnSubmit which i need to disable
using javascript
the document.getElementById("btn_Submit").Enabled=fals e returns an error
and the
document.getElementById('_ctl0_ContentPlaceHolder1 _btnSubmit').Enabled=false
works fine but how can i get that _ctl0_ContentPlaceHolder1_btnSubmit' ? now
i looked in the "view source" of the actual page

thanks,
akis

Feb 20 '06 #2
Hi,
The reason script is not working because there is no property called
Enabled in JavaScript,
every one make this mistake. To disable a control use Disabled property
See the following link for HTML reference
http://msdn.microsoft.com/library/de...node_entry.asp

Can you see a property called Enabled...????

Hope the following code might help you...
<script language="JavaScript">

function test()

{

document.getElementById("Button1").disabled=true

}

</script>

<body onload="test()">

<form id="form1" runat="server" >

<div>
<br />

<asp:Button ID="Button1" runat="server" Text="Button" /></div>

</form>

</body>

vinu

"akis" <ak**@discussions.microsoft.com> wrote in message
news:E1**********************************@microsof t.com...
Hello,
I have one button in the aspx page called btnSubmit which i need to
disable
using javascript
the document.getElementById("btn_Submit").Enabled=fals e returns an error
and the
document.getElementById('_ctl0_ContentPlaceHolder1 _btnSubmit').Enabled=false
works fine but how can i get that _ctl0_ContentPlaceHolder1_btnSubmit' ?
now
i looked in the "view source" of the actual page

thanks,
akis

Feb 20 '06 #3
don't you mean something more along the lines of:

document.getElementById("<%=myControl.ClientId%>") ;

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Stefan Brueggemann" <St***************@discussions.microsoft.com> wrote in
message news:0B**********************************@microsof t.com...
You can get the ID of the control on the clientside via the ClientID
property
of the control. So when you render the script in your code do it in this
way:
document.getElementById('" + myControl.ClientID + "');

At least this works for me.
"akis" wrote:
Hello,
I have one button in the aspx page called btnSubmit which i need to
disable
using javascript
the document.getElementById("btn_Submit").Enabled=fals e returns an error
and the
document.getElementById('_ctl0_ContentPlaceHolder1 _btnSubmit').Enabled=false
works fine but how can i get that _ctl0_ContentPlaceHolder1_btnSubmit' ?
now
i looked in the "view source" of the actual page

thanks,
akis

Feb 20 '06 #4
thanks all three of you,
a compination of the answers gives me results

TextBox1.Attributes.Add("OnChange", "getElementById('"+Button1.ClientID+
"').disabled=true");
Feb 20 '06 #5
If it's done in the aspx file then do it your way, in the code behind file
when you render it somehow like output.write(...) then in my way. ;)

"Karl Seguin [MVP]" wrote:
don't you mean something more along the lines of:

document.getElementById("<%=myControl.ClientId%>") ;

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Stefan Brueggemann" <St***************@discussions.microsoft.com> wrote in
message news:0B**********************************@microsof t.com...
You can get the ID of the control on the clientside via the ClientID
property
of the control. So when you render the script in your code do it in this
way:
document.getElementById('" + myControl.ClientID + "');

At least this works for me.
"akis" wrote:
Hello,
I have one button in the aspx page called btnSubmit which i need to
disable
using javascript
the document.getElementById("btn_Submit").Enabled=fals e returns an error
and the
document.getElementById('_ctl0_ContentPlaceHolder1 _btnSubmit').Enabled=false
works fine but how can i get that _ctl0_ContentPlaceHolder1_btnSubmit' ?
now
i looked in the "view source" of the actual page

thanks,
akis


Feb 21 '06 #6

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

Similar topics

6
by: MNF | last post by:
Hi everyone, I am using document.getElementById function in JavaScript to find a control within an html body, but instead I get back META item, because incidently the name of one meta tags is the...
7
by: PaulB | last post by:
Good Morning everybody, I'm trying to adapt a tutorial script that will handle the behaviour of an "Expanding/Contracting" site-navigation menu. The code that seems to handle the expansion and...
10
by: Geoff Cox | last post by:
Hello, Would appreciate a little help here! How do I refer to multiple elements with IDs such as question1, question2, question3 etc, in following? ...
11
by: ctman770 | last post by:
Hi Everyone, Is it faster to save the precise location of an html dom node into a variable in js, or to use getElementById everytime you need to access the node? I want to make my application...
9
by: jason.hau | last post by:
Ok, interesting problem here, I have a webcontrol that holds a textbox and a requiredfieldvalidator from System.Web.UI.Webcontrols in .NET 2.0 (this is javascript related, bear with me). The...
1
by: mhito | last post by:
hi guys, My first post yes. Thanks for all the nice posts and threads in this forum - great stuff. Now, here's my question: First off, the url : http://catfish.businesscatalyst.com/bcimg.htm...
4
by: Bjorndal | last post by:
I'm new to javascript, so I figure som of you guys in here can answer my question pretty easily: I have this code which works: <script type="text/javascript"> </script> </head> <body>
29
by: Nick | last post by:
I've seen a few frameworks use the following: function $(id) { return document.getElementById(id); } Then to use: $('something').innerHTML = 'blah'; I'm just trying to roll this out to my...
8
by: cyqotiq | last post by:
First, let me state that this is not necessarily a Firefox problem, as I haven't fully tested in IE just yet. Second, let me state that this is not the typical "getElementById not working Firefox"...
3
by: GarryJones | last post by:
The following works in MSIE but not firefox. I suspect it has something to do with the fact that the element I am trying to access is not the "tid" which is the name of the DIV that is passed to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.