Results 1 to 2 of 2

Thread: Can't access textbox

  1. #1

    Thread Starter
    Hyperactive Member mrmojorisin's Avatar
    Join Date
    Oct 2007
    Location
    London Town Vocation: Garden Cricket Genuis
    Posts
    439

    Can't access textbox

    Hi,
    New to this so apologies in advance.
    I am just trying to access a textbox and give it a value using this code:
    Code:
    <script type="text/javascript" language="javascript">
    function FocusSelected()
    {
    document.getElementById('TextBox1').value = "hello"
    return(true);
    }
    </script>
    The problem is the text box is on a form view on a mutliview on a tab container and i think this is the reason the code does not find the text box. I get the following error: document.getElementById(...)' is null or not an object

    Can anyone help?
    Thanks
    Mojo

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Can't access textbox

    If it's ASP.NET you're using, you should stick to the ASP.NET forum as it has its own 'quirks'.

    In your case, I am guessing that the actual rendered ID of the textbox control is not TextBox1. Do a view source and see for yourself. You will need to generate the call to the function in the codebehind or generate the javascript in the codebehind, because that's where you have access to the .ClientID property. (TextBox1.ClientID)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width