Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Set focus problem

    I have a page with a drop down and several web controls. The drop down
    is set to postback and it reloads the textboxes based on the selected
    drop down item. I set the focus to the first textbox control on the
    client like this:
    <script language="vbscript">
    Option Explicit
    ....other code
    If Not <%=mbReadOnly%> Then
    document.frmDetails.txtName.focus()
    End If
    ....other code
    </script>
    This works fine on first page load but when I change the drop down it
    does reset the focus and you can't even type in the first textbox
    until you select another textbox first.
    To debug I added a message box right before the set focus to see if it
    was even getting to this line of code and it works but I can't leave a
    message box here.
    Any ideas on what could be the problem?
    Thanks in advance for any help,
    Deidre
    Deidre Guest

  2. Similar Questions and Discussions

    1. Focus problem w/player 8.5 & 9
      I'm using flash 8, and it's regular html deployment methond (code). Ever since I got player 8.5 and now 9 I have to click once on my movie to bring...
    2. ComboBox Focus Problem
      Hello All, I've been playing around with populating a ComboBox with a list of the fonts on the user's machine and allowing the user to apply one...
    3. Combo Box Focus Problem
      I need some help. I have a combo box set so you can edit the fields. I want the focus to be initially in the text field in the combo box. This is...
    4. Popup; show, take focus, wait for button action, give focus, hide
      Hi. I've got a popup MC for displaying a message or asking a yes/no question that has to do the following on an event: - show and take focus...
    5. Focus problem
      hi there.... it seems that when we change an html with swf in side in the same frame (html) the mouse lose his focus until you click it or move...
  3. #2

    Default Set focus problem

    Hi

    setfocus in body onload event,

    document.frmDetails.txtName.focus()

    HTH
    Ravikanth

    >-----Original Message-----
    >I have a page with a drop down and several web controls.
    The drop down
    >is set to postback and it reloads the textboxes based on
    the selected
    >drop down item. I set the focus to the first textbox
    control on the
    >client like this:
    ><script language="vbscript">
    >Option Explicit
    >....other code
    >If Not <%=mbReadOnly%> Then
    >document.frmDetails.txtName.focus()
    >End If
    >....other code
    ></script>
    >This works fine on first page load but when I change the
    drop down it
    >does reset the focus and you can't even type in the
    first textbox
    >until you select another textbox first.
    >To debug I added a message box right before the set
    focus to see if it
    >was even getting to this line of code and it works but I
    can't leave a
    >message box here.
    >Any ideas on what could be the problem?
    >Thanks in advance for any help,
    >Deidre
    >.
    >
    Ravikanth[MVP] Guest

  4. #3

    Default Re: Set focus problem

    Thanks for the suggestion but it does the same thing if I put it in a
    body onload event.

    "Ravikanth[MVP]" <dvravikanth@hotmail.com> wrote in message news:<0e1c01c34d31$17c134a0$a301280a@phx.gbl>...
    > Hi
    >
    > setfocus in body onload event,
    >
    > document.frmDetails.txtName.focus()
    >
    > HTH
    > Ravikanth
    Deidre Guest

  5. #4

    Default Re: Set focus problem

    I fixed my problem. I needed to move my set focus command to the window_onload sub:
    Sub Window_OnLoad()
    If Not <%=mbReadOnly%> Then
    document.frmDetails.txtName.focus()
    End If
    End Sub

    Deidre
    Deidre Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139