Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.Net 1.1 Client Script

Reply
Thread Tools

ASP.Net 1.1 Client Script

 
 
=?Utf-8?B?Z24=?=
Guest
Posts: n/a
 
      02-24-2006
I have an asp.net page with client side javascript. In the script I can get
a control and read its properties by using
document.getElementById('txtDBName'). But if I try to set any of the
properties of this control it doesn't work; for example the code line
document.getElementById('txtDBName').value = 'hosted';. Can anyone explain
why this is.

I have other pages where I do the same thing in client javascript and those
pages work fine but on this one page this doesn't work. I have compared
pages and I see no differences in the page that doesn't work and the page
that does work.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      02-24-2006
The statement document.getElementById('txtDBName').value = 'hosted'; would
fail to produce an outcome if there were no control with that ID found. This
could happen if you are referring to a server control that is within another
server control (e.g. a textbox within a datagrid) where the ClientID would
look like this: datagrid1:txtDBName.

Try always to check if the getElementById function returned a null or an
object, e.g.
var txtBox = document.getElementById('txtDBName');
if (txtBox!=null)
{
txtBox.value = "hosted";
}
else
{
alert("could not find a textbox with id='txtDBName'" );
}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"gn" wrote:

> I have an asp.net page with client side javascript. In the script I can get
> a control and read its properties by using
> document.getElementById('txtDBName'). But if I try to set any of the
> properties of this control it doesn't work; for example the code line
> document.getElementById('txtDBName').value = 'hosted';. Can anyone explain
> why this is.
>
> I have other pages where I do the same thing in client javascript and those
> pages work fine but on this one page this doesn't work. I have compared
> pages and I see no differences in the page that doesn't work and the page
> that does work.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
RE: How to execute a script from another script and other script doesnotdo busy wait. VYAS ASHISH M-NTB837 Python 2 01-07-2010 08:18 PM
Odd script error when using client script callbacks (ASP.NET 2.0) =?Utf-8?B?TG93bGFuZGVy?= ASP .Net 0 03-27-2007 10:30 PM
Client side script after client side validation with asp.net 2.0 Boss302 ASP .Net 0 11-21-2006 08:43 AM
Server-side script with input parameter from Client-side script Magnus Blomberg ASP .Net 3 04-14-2005 12:21 PM



Advertisments