Determine if control exists

Results 1 to 2 of 2

Thread: Determine if control exists

  1. #1
    Join Date
    Dec 1969

    Default Determine if control exists

    Is there a way to determine with JScript if a control exists before I access it? For instance. In a lot of my pages, in the &#060;body&#062; tag, I usually do the following, onload="javascript:document.form1.Password.focus() " to set focus to the first field. However, sometimes, after the user submits the form, I remove the previous form (using ASP.NET Panels) and simply display a message about the user&#039;s submition of the form. This, of course, causes a JScript error, because the control that I&#039;m referring to no longer exists. However, if I move the code to a function, and check for the existence of the control before attempting to set focus to it, that would solve the problem. But, I don&#039;t know how to do that. I could also redirect it to another page, but I don&#039;t really want to have a whole page that simply displays a message of some sort, and that is all. I&#039;d rather keep it all on one page if I can.<BR><BR>Any hints?<BR><BR>Thanks,<BR>Jesse

  2. #2
    Join Date
    Dec 1969

    Default RE: Determine if control exists

    if(document.form1.Password)<BR>{<BR> document.form1.Password.focus();<BR>}

Posting Permissions

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