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

ASP.Net 1.1 Client Script

gn
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.
Feb 24 '06 #1
1 1938
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.

Feb 24 '06 #2

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

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
5
by: tmb | last post by:
Is there a way to use ASP to 'push' a new image to the client every 15 seconds or so? I guess the entire page will have to be 're-sent' to the client but I'm not sure. I'm trying to 'rotate'...
26
by: Don | last post by:
I'm writing an html page with some JavaScript that reads a web page into a client-side temp file, then reformats it, then submits that same file as a URL to the browser for display, via...
4
by: Bob T | last post by:
Hi All, I am trying to pass a variable from my VB asp.net script (from for example Sub Page_Load in mypage.aspx.vb) to my Client side script. I have found and looked at a very good example...
9
by: Harry Smith | last post by:
While reading the documentation on IsStartupScriptRegistered, there is a reference to "client startup script" as "Determines if the client startup script is registered with the Page object." What...
7
by: lvpaul | last post by:
Hallo ! I am using IIS-Windows-Authentication in my intranet (web.config <authentication mode="Windows" /> <identity impersonate="true" /> How can I get the users (client) IP-Address ? I...
3
by: SimonZ | last post by:
In ASP.NET 1.0 all client ID's of controls run at server were the same as the rendered ones on the client. In ASP.NET 2.0 the client id of server control is different on server than on the...
7
by: Mike Rand | last post by:
I am having a really hard time trying to get some client side code hooked up in VS2005, ASP 2.0. The code is in an .inc file (vbscript). The first problem I am encountering is the ASP.NET page...
5
by: Bjorn Sagbakken | last post by:
Hello I have just migrated from VS 2003 to VS 2005, and .NET framework 1.1 to 2.0 I am at the end of debugging and fixing stuff. Now there is one error I just cannot find a solution to: On...
3
by: jesper_lofgren | last post by:
Hello, I have a problem, i have a event in asp.net codebehind file that updating a datasource. If that update went well i want to refresh my treeview thats on another page. The script works...
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...
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)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.